I have an ASP.Net 4.0 Web Service method that returns a well-formed XML document. I successfully display XML in a browser locally and once deployed to a production server.
When I try to call a method through jQuery ajax, I get an error:
XML parsing error: no items were found. Location: moz-nullprincipal: {6c0c99b3-0fed-454f-aa6e-e0fca93a521c} Line number 1, column 1:
$.ajax( { url: 'http://mywebservice.com/WebService/Service.asmx/UserData', type: 'GET', contentType: "text/html; charset=utf-8", dataType: "xml", data: 'authorizedId=1234&authorizedUser=Test&authorizedCode=xyz', 'success': function (data) { $('#XMLContent').html(data.responseText); }, 'error': function (xhr, status) { alert(status); }, 'complete': function (xhr) { } });
I tried changing the contentType, but the same results.
However, I can make a call in C # like this, and I get my well-formed XML:
XmlDocument document = new XmlDocument(); document.Load("http://mywebservice.com/WebService/Service.asmx/UserData?authorizedId=1234&authorizedUser=Test&authorizedCode=xyz"); ViewData["XMLData"] = document.OuterXml;
In my web.config web service:
<webServices> <protocols> <add name="HttpGet"/> <add name="HttpPost"/> </protocols> </webServices>
Thanks...
source share