I ran into an issue while trying to retrieve some jsonp data from another Host. That's my setup:
Client on 192.168.2.107 running on Raspbian
Host on 192.168.2.109 running apache2 on raspbian
Client is able to get the web Page pump.php from Host via Web Browser.
Code on Client:
$.ajax({
url: 'http://192.168.2.109/pump.php',
dataType: 'jsonp',
success:function(result) {
console.log(result);
},
error:function (xhr, ajaxOptions, thrownError) {
console.log(xhr);
alert(thrownError + xhr.status);
}
});
Code on server (pump.php):
header("Content-Type: application/json");
echo "myCall({foo:'bar'});";
I always get a 404 response from the host. Though I'm completely out of ideas what's wrong with my code or something else or even how I should try to troubleshoot this, any help is higly appreciated! Thanks in advance.
[EDIT] Forgot to mention that myCall() is specified in the client as well:
function myCall(data) {
console.log(data);
}
Aucun commentaire:
Enregistrer un commentaire