I am developing a web app with html5, javascript with a php server, my problem is in a ajax call in the javascript:
$.ajax({
type: "POST",
url: "http://localhost/pos.php",
data: "lat="+lat+"&lon="+lon+"&nome=helena",
dataType: "JSON",
success: function(data){
data = $.parseJSON(data);
console.log(data + " im here!!");
},
error: function(jqXHR, textStatus, errorThrown ){
console.log("POST: ", jqXHR, textStatus, errorThrown);
}
});
And from the side of the php I run a script, and in the end I do:
$arr = array ( 'a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5 );
echo json_encode($arr);
The php returns the array, but from the side of the javascript, I can't access it in the success function, in the console it says:
POST: [url=""]Object { readyState=0, status=0, statusText="error"}[/url] error (an empty string)
What am I doing wrong? I have tried to do it in lots of ways I saw in the internet, but I can't get it to work, can someone help me?