I send a post-request to the server, and php responds with an array, but I cannot extract the values from the array
I am transmitting 2 values from a php server to js like this (PHP):
$idp = mysqli_fetch_array(mysqli_query($db, "SELECT idp FROM videos WHERE idv = '$idv'"))['idp']; $p = mysqli_fetch_array(mysqli_query($db, "SELECT login FROM accounts WHERE idp = '$idp'"))['login']; $data = [ 0 => $idp, 1 => $p ]; $data = json_encode($data); echo($data); And I extract it like this:
function(arr){ var idp = arr[0]; var p = arr[1]; But I get the wrong values, what I convey, what is wrong and how to fix it?