I load XML from aspx page by MSXML2.DOMDOCUMENT.3.0 ActiveXObject.
var xmlDoc = null;
try {
xmlDoc = new ActiveXObject("MSXML2.DOMDocument.3.0");
xmlDoc.setProperty("SelectionLanguage", "XPath");
}
catch (e) {
window.alert("CreateXMLDocument failed due to the following problem: " + e.description);
}
if (xmlDoc != null) {
xmlDoc.async = false;**
var result = xmlDoc.load("xmlData.aspx");
if (result == false) {
window.alert("failed to load xml due to the following problem: " + xmlDoc.parseError.Reason);
}
else {
window.alert(xmlDoc.selectSingleNode("//RESULT").text);
}
}
aspx page that provides xml data:
<%@ Page Language = "JScript" EnableSessionState="ReadOnly" %>
<% Response.Buffer = true %>
<%
Response.ContentType = "text/xml";
Response.Write("<?xml version='1.0'?>");
Response.Write("<RESULT>1</RESULT>");
%>
- If these two pages are running under http, I can get popup saying "1" in IE9;
- If these two pages are running under https, I only can get the error popup, which means xml is not loaded successfully.
- But if I change xmlDoc.async = true and use ondataavailable callback function to get data, it will popup "1".
Any idea about this?
UPDATE: I figured out that XMLDOM could not load xml synchronously from https in IE9, and then used XMLHTTP to load xml with no problems. But now the problem is XMLHTTP-loaded xslt could not be used to transform xml.
UPDATE AGAIN: It's not correct to say that XML DOM could not load x开发者_运维知识库ml synchronously from https in IE9. In IE9 Internet Options --> Advanced --> Security --> "Do not save encrypted pages to disk", if you have it checked, the issue occurs. Uncheck it, problem is solved.
You should read this for an explanation: http://blogs.msdn.com/b/ieinternals/archive/2011/05/07/downloads-and-flash-fail-when-do-not-save-encrypted-pages-to-disk-is-set.aspx
精彩评论