讀dwr的engine.js源碼,看到convertXml這個方法:
[xhtml:showcolumns]
·········10········20········30········40········50········60········70········80········90········100·······110·······120·······130·······140·······150
/**
* Marshall an object
* @private
* @see dwr.engine.serialize.convert() for parameter details
*/
convertXml:function(batch, referto, data, name, depth) {
var output;
if (window.XMLSerializer) output = new XMLSerializer().serializeToString(data);
else if (data.toXml) output = data.toXml;
else output = data.innerHTML;
return "xml:" + encodeURIComponent(output);
}
裡面用瞭XMLSerializer,這個在IE6下面不支持。
toXml,ff和ie6下面都undefined,估計是自定義轉化xml的方法名吧。
最後一個data.innerHTML,是針對html dom對象的。
如果過傳的是對象是構造的xml對象,如下構造的:
[xhtml:showcolumns]
·········10········20········30········40········50········60········70········80········90········100·······110·······120·······130·······140·······150
function stringToXML(xmlData){
if (window.ActiveXObject) {
//for IE
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
xmlDoc.loadXML(xmlData);
return xmlDoc;
}
else
if (document.implementation && document.implementation.createDocument) {
//for Mozila
parser = new DOMParser();
xmlDoc = parser.parseFromString(xmlData, "text/xml");
return xmlDoc;
}
}
這樣傳進去隻有在ff下測試成功,執行的是這個方法XMLSerializer,IE6下報錯error,
在網上查瞭下,上面說的ie9支持XMLSerializer這個。
呵呵。。。小弟看源碼和測試的結果,不知道有錯沒,如果有請看到的大牛們指出來,謝謝?
摘自 懶人小何