Got kind of a tricky problem.
I\'m working on a project where we need to allow receipt printouts when users check out on our site at a kiosk. For reasons relating to
JSONP simply adds a script
tag to the head
section and thus is limited only to GET requests. In order to configure your asmx web service to handle JSONP you will need to handle serialization manually:
[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);
}
And the client side:
$.getJSON("http://192.9.200.165/ContestWebService/Service1.asmx/PrintOrderReceiptJson?jsoncallback=?",
function(data) {
alert(data);
});
Another alternative for cross domain AJAX calls is to use Flash.