I am attempting to make a jsonp call with jQuery 1.7 but when the call returns I get the following error:
Uncaught TypeError: Object function ( response ) {
responseContainer = [ response ]; } has no method ‘json’
When inspecting the data being returned I noticed that ‘.json’ is being appended to the callback function name:
jQuery17206211688306648284_1336426518269.json({"..."})
Here is the code that is making the request:
$.ajax({
url: "...",
dataType: 'jsonp',
success: function(data) {
return console.log(data);
}
});
Answer:
As adeneo said the server was trying to specify a callback function of ‘json’ this is handled by setting the following parameter on the $.ajax call:
jsonpCallback: 'json'
jQuery’s $.ajax function automagically adds a callback function to jsonp requests, but it looks like the
json()function you are seeing is added by the server, but you could try :To disable the jQuery auto callback thingy, or just create an empty chainable function with the name
json()