JSONP只是
script向该
head部分添加标签,因此仅限于GET请求。为了将您的asmx
Web服务配置为处理JSONP,您将需要手动处理序列化:
[WebMethod][scriptMethod(UseHttpGet=true, ResponseFormat=ResponseFormat.Json)]public string Foo(){ var json = new JavascriptSerializer().Serialize(new { Prop1 = "some property", }); string jsoncallback = HttpContext.Current.Request["jsoncallback"]; return string.Format("{0}({1})", jsoncallback, json);}和客户端:
$.getJSON("http://192.9.200.165/ContestWebService/Service1.asmx/PrintOrderReceiptJson?jsoncallback=?", function(data) { alert(data); });跨域AJAX调用的另一种替代方法是使用Flash。



