$.ajax() problem in IE, but not in Firefox and Chrome... encoding issue?
I'm using $.ajax() on a webpage to fetch a XML result from a classic ASP page.
This works fine in all browsers as long as there are no special characters like the Euro sign in the XML result.
Once there is such a character in the XML result, Internet Explorer reports: "DOM exception: syntax error (12)". But other browsers like Firefox and Chrome don't have this problem. They process the XML result just fine.
I guess this must be an encoding issue or something like that. But I don't understand why the other browsers are not reporting that same issue.
My (shortened) jQuery call is like this:
- function wsGetTemplateDetails() {
//
var l_oTemplates = $('#numTemplateID').get(0);
var l_iID = l_oTemplates[l_oTemplates.selectedIndex].value;
var l_sURL = '/wsadmin/ajax_emailtemplates.asp';
$('body').css('cursor', "progress");
$.ajax({
type: "get",
url: l_sURL,
data: "action=getemailtemplatedetails&id=" + l_iID,
dataType: "xml",
error: function(XMLHttpRequest, textStatus, errorThrown){
alert('Error loading XML document: ' + errorThrown);
},
success: function(xmlData){
var l_oNode;
try {
var l_oMessage = $('#memMessage').get(0);
if (l_oMessage) {
l_oNode = $(xmlData).find('Html');
if (l_oNode && l_oNode.text().length > 0) {
$('#memMessage').val(l_oNode.text());
}
}
}
catch(err) {
//Handle errors here
}
$('body').css('cursor', '');
}
});
$('body').css('cursor', '');
}
The classic ASP which is triggered by the $.ajax() call has 'Response.ContentType = "text/xml; charset=utf-8;" ' and is using MSXML2.DOMDocument.6.0 to build the XML document.