JQuery- $(xmlObject).xml does not work in Mozilla but works in Internet Explorer
function parseXml(xml)
{
xmlObject= xml;
alert(xmlObject.xml);
}
function close(errroMsg)
{
//Displayed Error Message
}
$(document).ready(function()
{
$.ajax(
{
type: "POST",
开发者_C百科 url: "ServiceProvider.aspx",
dataType: "xml",
success: parseXml,
failure: close
}
);
});
In IE-8 the alert(xmlObject.xml) disaplays xml string. but in Mozilla it displays undefined. I am using jquery-1.4.2 I was unable to figure out the error. Thanks in Advance.
IE has a slightly different implementation of XML documents from other browsers, one of the differences being that in IE there is an xml
property of the document.
If you want to serialize the XML into a string in all browsers, you can use the following:
function serializeXmlDoc(xmlDoc) {
if (window.XMLSerializer) {
return (new window.XMLSerializer()).serializeToString(xmlDoc);
} else if (typeof xmlDoc.xml != "undefined") {
return xmlDoc.xml;
}
}
精彩评论