I'm trying to get bool from a webmethod, but got xml string instead. Don't want to parse XML on client. In .net MVC i've achieved it simply by returnin' JSON, how to make the trick via WebForms?
The webmethod:
[System.Web.Services.WebMethod]
public bool MyService(string _container)
{
return true;
}
The AJAX call:
$.ajax({
type: "POST",
url: '/WebMethods.asmx/MyService',
contenttype: "application/json; charset=utf-8",
data: { _container: JSON.stringify(params) },
datatype: 'json',
success: function (data) {
if(data) {
MakeStuff();
}
}
});
What i've got:
<boolean xmlns="%myWebmethodUrl%">true</boolean>