StackOverflower
StackOverflower

Reputation: 5761

Error doing a jsonp ajax call

Using this code

$.getJSON("http://mydomain.com/getcustomers?callback=?",function(data) {  
....
}).error(function(err){
....
})

I'm getting

jQuery16103492487950357067_1336742910384 was not called

I searched on google and some people points to a incompatibility with jquery validate, I'm not using that plugin on this page. I also tried to replace the $.getJSON call by a $.ajax call in order to have more control but the result is the same.

Anyone knows what is causing this?

Upvotes: 0

Views: 109

Answers (1)

S P
S P

Reputation: 4643

Does the service where GetCustomers method lives really support JSON-P? You should be able to see the responses in Fiddler.

You can install Fiddler. Download it from www.fiddler2.com. In case of JSON-P, the JSON-part is wrapped by a function call.

Your response will look like this:

enter image description here

Basically, it is a hack in order to get around the same-origin policy, but since parties such as Google are using it heavily as well, you can "safely" use it. What is returned by the server is actually a javascript function.

Upvotes: 1

Related Questions