My jQuery is below:
var x = $.ajax({
dataType: "jsonp",
url: "https://ajax.googleapis.com/ajax/services/search/images?q=google&v=1.0",
success: function(msg){
alert( "Jsonp data: " + msg );
}
});
alert(x); // x is undefined
// x.abort()
I want stop this ajax request and stop this ajax request's success function.
But what I get is that "x" is undefined , I think I doesn't stop this ajax request and its success function.
So can anyone help me?
Thank you very much!
解决方案
Well that makes sense.
A jsonp call is not an ordinary XMLHttpRequest (which .ajax() normally returns). It would not work that way since you cannot break out the same origin policy.
JSON-Padding works with dynamic script tag insertion. So basically, jQuery just creates a tag on your site and loads the data over that. No XHR object at all.
I don't think there is a way to early abort that kind of request, but I hope someone will correct me here if I'm wrong.