My ASMX call is returning Content-Type = text/xml; charset=utf-8
I am using ASP.NET 3.5 and jQuery.Ajax
.
Have added these things are per numerous suggestions from Stack Overflow
I have done these things
Done this at web.config
<remove verb="*" path="*.asmx"/> <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
On the function call inside ASMX, I am using these
<WebMethod()> _ <ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _ Public Function GetCompanies(SearchedCompany As String) As String
the jQuery Ajax call is like this
var searchString = "SearchedCompany=" + $(".auto-company").val(); $.ajax({ type: "POST", url: "Services/CompaniesService.asmx/GetCompanies", data: searchString, dataType: 'json', success: function (msg) { companies = msg.hasOwnProperty("d") ? msg.d : msg; }, error: function (xhr, status, error) { } });
But whatever I do, the response header is still of type xml. What part am I missing here?
Disclaimer: I know this has been asked many times around here. But was not able to find any answer. As you can see, I have already implemented all of the solutions provided.