I am trying to create an ajax request to a WebService that returns data with given parameters in XML. This seems to work in IE, but Firefox cannot decode the response. I can also view the response in Fiddler after decoding. Here is the code:
$(function() { $.ajax({ type: "GET", url: 'http:/localhost/webservice.asmx/GetTags?groupId=10', contentType: "text/xml; charset=utf-8", dataType: "xml", success: function(response) { $('#result').html('success',response); $(response).find("string").each(function() { $('#result').append($(this).text()); }); }, error: function(response) { $('#result').html('failure',response); } }); });
Can I specify which response to decode? Or any other way to make it work?
EDIT: @ Nikki9696 is not JSON encoded as the data is returned in XML.
@Oleg is a sample XML that I can see in the browser if accessing the web service through the URL looks like this:
<?xml version="1.0" encoding="utf-8"?> <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/"> <string>tag 1</string> <string>tag 2</string> <string>tag 3</string> </ArrayOfString>
Violinist in TextView returns and message
"The response is encrypted and may be required before decoding. Click here to convert."
After clicking on it, the same XML is displayed. I turn off dynamic compression of content in IIS, then XML is immediately visible in the script, but FF still canβt cope, so it excludes compression.
I played around a bit with the script, it seems that jQuery can by default or guess some parameters, so dataType, for example, is optional. With these settings, I get a success message, but he still does not know what to do with the data. I tried to set dataType to "jsonp", as suggested in some SS thread (I canβt find it at the moment, will bind it when I do this), and the error will change to missing ; before statement missing ; before statement , I think, because this is not a JSON object, but XML, Is there a way to force webservice to return JSON instead?
EDIT 2: I updated the url to reflect what actually happened. Sorry, I skipped this, making it impossible for anyone to notice it.