I need to do a JSONP call.
Ajax function call :
$.ajax({
url: myPath,
dataType: 'jsonp',
success: function(data) {
alert("hello");
}
});
getJSON function call :
$.getJSON(myPath + '&callback=prova?', function(data) {
alert("hello");
});
with getJSON (using &callback=prova for setting JSONP protocol) I get an error 200. .ajax() works as well. Why? I want to use getJSON here...
You should use callback=?
and not callback=prova?
if you want your request to be treated as JSONP:
$.getJSON(myPath + '&callback=?', function(data) {
alert("hello");
});
Try this
$.getJSON(myPath + '?callback=prova', function(data) {
alert("hello");
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.