UPDATE 1:
I've just upgraded from jquery 1.4.4 to 1.6.1. How does that effect the script in the original question?
ORIGINAL QUESTION:
Just as I test, I did:
$(document).ready(function() {
get_jsonp_feed();
function get_jsonp_feed() {
$.ajax({
url: 'http://www.remote_host.co.uk/feed.php',
type: 'GET',
dataType: 'jsonp',
jsonp: 'callback',
jsonpCallback: 'jsonpCallback',
error: function(xhr, status, error) {
alert("error");
},
success: function(jsonp) {
alert("success");
}
});
}
function jsonpCallback(data){
alert("jsonpCallback");
}
});
I was expecting to get 2 alerts, the first showing success
and the second showing jsonpCallback
. But I am only getting the first alert success
. Why is the second alert not showing up?
George is correct, set the jsonp param to false -- as of jQuery 1.5 (so, how you set this up is jQuery version dependent). I don't believe that your supplied callback name is invoked as a function (rather, it is the name provided in the URL presented to the server). If you are getting success, then you have received the data. Curious: do you have a hosts entry set up for dev, because I tried to do some testing, and http://www.remote_host.co.uk/feed.php does not resolve for me.