I am doing a cross-domain fetch from a ASP.NET page using Jquery-JSONP
My ASP.NET page looks like this;
public partial class Test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("functionName({'test_param':12345});");
}
}
This is hosted on my server as test.aspx
I am now using JQuery from localhost and trying to fetch the data from test.aspx like this;
$.ajax({
dataType: 'jsonp',
url: 'http://abc.com/GTalk/test.aspx?callback=?',
success: function () {
alert("Success");
},
error: function (x, y, z) {
alert("error" + x.responseText);
}
});
I am getting an error x.responseText = "undefined"
The error, z, is Error: jQuery171008073005825281143_1328259709467
I am not able to figure out what mistake I am doing. I am a newbie.
Thanks.
Instead of “functionName” on serverside you must print the function-name you receive via the GET-params as callback-parameter(jQuery171008073005825281143_1328259709467 in that case).
You can’t hardcode the name, it differs on every request)