First off, most threads and documentation on this are very very old, so I wonder whether there is some newer technology I don't know, that actually is an improvement on the situation.
However, I am trying to call a WebMethod via JQuery-Ajax and have it return a JSON object.
So I am using:
$.ajax({
type: 'GET',
url: 'ajaxtest.asmx/getData',
success: function (data) { console.log(data) } [...]
and on the server side
<WebMethod()>
<ScriptMethod(UseHttpGet:=True, ResponseFormat:=System.Web.Script.Services.ResponseFormat.Json)>
Public Function getData() As String
Return getJSONFromDatatable(dt)
End Function
Now the server-code runs, and the JSON-serialization is no problem, but then I get some entirely different object which kind of looks like an document-object.
My web.config looks like this
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
<system.webServer>
<handlers>
<add name="ajax" verb="*" path="*.asmx"
type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</handlers>
</system.webServer>