I always see the code like this in the blogs:
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "WebService.asmx/HelloWorld",
data: "{}",
dataType: "json",
success: function(msg) {
alert(msg.d);
}
});
But I think this is run only with asp.net 3.5. I couldn't run it with 2.0. How can I use such these codes in my Applications?
You need to add this attribute to your webserver class
[System.Web.Script.Services.ScriptService]
public class Service : System.Web.Services.WebService
and this attribute to your functions
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
You don't technically need to specify the responseformat, as it responds according to the format you specify in the request. And you must specify a format in the request.
Regards
K