I'm trying to use jsonp with jQuery but I get inconsistent behaviors. Sometimes the script works, sometimes it does not; I don't really understand why.
This is the error that may be displayed by Chrome:
Uncaught TypeError: Property 'jQuery18208278296771459281_1362854738133' of object [object Object] is not a function
In the following example, I'm only trying to check whether the application is online or not. But this inconsistent behavior may happen on other similar ajax calls:
$.ajaxSetup({
error: function (req, status, ex) {},
success: function (data, status, req) {},
timeout: 2000,
crossDomain: true,
contentType: "application/json",
dataType:"jsonp",
url: "http://myUrl.com/ping.php?preventCache="+new Date()
});
return $.ajax();
The server side PHP file is pretty simple too:
<?php
header("Content-Type: application/javascript; charset=UTF-8");
echo $_GET['callback'];
?> ({ "status": "online" })