Well, that should be a fairly simple question, and I probably don't see anything obvious. I have a simple script request to the server:
var DTO = { 'path': path };
var url = 'default.aspx/Get';
var test;
$('#getInstance').click(function () {
$.ajax({
url: url,
type: 'POST',
dataType: 'json',
data: JSON.stringify(DTO),
contentType: 'application/json; charset=utf-8',
success: function (msg) {
test = msg;
},
error: function (jqXHR, textStatus, errorThrown) {
alert(textStatus);
alert(errorThrown);
}
});
});
This works great because it connects to the server and returns data with one simple problem. It processes this request as a cross-domain request, therefore using jsonp. Server code is here:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static MyObject Get(string path)
{
MyObject foo = new MyObject();
return foo;
}
This is usually not a problem, except that I am accessing WebMethod and it has no way to return a jsonp response (this means that it has no way to bind the callback function to the answer. Manual answer, I could crack it and attach the parameter but I use built-in serialization, so I wonโt interfere with the reaction.
To help clarify. The page is located at:
http://127.0.0.1:144/default.aspx
, firebug, :
http://127.0.0.1:144/default.aspx/Get?callback=jQuery1502768168154247801_1298656485388
, . , jQuery -. ?
: , , โโjquery 1.5.1. ( 1.4), , JSON, . , , CORS?