我需要从跨域获取 json 数据。
$.getJSON('http://xx.xx.xx.xx/SampleService/Handler.ashx?callback=?', data, function (jsonData) {
alert('1');
})
.done(function () { console.log("second success"); })
.fail(function () { console.log("error"); })
.always(function () { console.log("complete"); });
处理程序代码:
context.Response.ContentType = "application/json";
SampleService service = new SampleService();
List<List<Byte>> response = service.GetData();
string jsonData = JsonConvert.SerializeObject(response);
context.Response.Write(string.Format("{0}([{1}]);", context.Request["callback"], jsonData));
我得到的错误是:
"parsererror"
Error: jQuery19108131180874027861_1366004862133 was not called