how to support JSONP returns in ASP.Net website for getJson calls?
var url = "http://demo.dreamacc.com/TextTable.json?callback=?";
$.ajax({
type: 'GET',
url: url,
async: false,
jsonpCallback: 'jsonCallback',
contentType: "application/json",
dataType: 'jsonp',
success: function (ooo) {
alert('hi');
alert(ooo);
},
error: function () {
alert('w');
}
});
the previous function doesn’t fire the neither the success nor the error function
On the server you could write a handler which will return JSONP response:
The idea here is that the generic handler will check for the presence of a
callbackquerystring parameter and if specified it will wrap the JSON into this callback.Now you could point the $.ajax call to this server side handler: