I have been looking on how to consume a webmethod using the $.ajax call using this code below:
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "WebService.asmx/HelloWorld",
data: "{}",
dataType: "json",
success: function(msg) {
alert(msg.d);
}
});
However when I tried to change the type from “POST” to “GET”, the call didn’t go through. Can someone please point out a reason why this happens?
By degault
GETrequests are disabled for ASP.Net AJAX Web services, ScottGu has an excellent blog entry on this, including how to bypass that security if that’s what you’re after.Here’s an example fix, by setting
UseHttpGeton theScriptMethodAttribute: