I have an ASP.Net web page attempting to retrieve data from an asmx webservice using the jquery .axax method. The ajax method correctly call a success method when the dataType = "text", however I cannot get it to return when using the dataType of "json". Can anyone see what I am missing? I am getting the 'json' example online at http://weblogs.asp.net/jaredroberts/archive/2009/08/28/great-article-on-cascading-dropdown-list-and-jquery.aspx
Client:
function getText() {
alert("getText");
$.ajax({
type: "POST",
url: "test.asmx/HelloWorld",
dataType: "text",
success: function(response) { alert("text"); }
});
}
function getJson() {
alert("getJson");
$.ajax({ type: "POST",
url: "test.asmx/HelloWorld",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(response) { alert("json"); }
});
}
Serverside Webservice Call:
[WebMethod]
public string HelloWorld() {
return "Hello World";
}