我想通過dojo.XHRGet
追加一些XML到dijit.layout.ContentPane
。在Firefox(3.6)中一切正常,但在Chrome中,我只返回特定ContentPane中的「未定義」。dojo/dijit ContentPane設置內容
我的代碼看起來是這樣的:
var cp = dijit.byId("mapDetailsPane");
cp.destroyDescendants(); // there are some existing Widgets/content I want to clear
// and replace with the new content
var xhrData = {
url : "getsomexml.php",
handleAs: "xml",
preventCache: true,
failOk: true
};
var deferred = new dojo.xhrGet(xhrData);
deferred.addCallback(function(data) {
console.log(data.firstChild); // get a DOM object in both Firebug
// and Chrome Dev Tools
cp.attr("content",data.firstChild); // get the XML appended to the doc in Firefox,
// but "undefined" in Chrome
});
因爲在這兩種瀏覽器我得到一個有效的Document
對象我知道XHRGet工作正常,但似乎是在內容如何是某種差異被設置。有沒有更好的方法來處理來自請求的返回數據?
有看到我的XML請求,所以這裏是它的一部分...
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
version="1.1" width="672" height="1674">
<defs>
<style type="text/css">
<![CDATA[ ...bunch of CSS...
]]>
</style>
<marker refX="0" refY="0" orient="auto" id="A00End" style="overflow: visible;">
...bunch more defs...
</defs>
<g id="endpoints">
...bunch of SVG with a some...
<a xlink:href="javascript:gotoLogLine(16423,55);" xlink:type="simple">...more svg...</a>
</g>
</svg>
我已經運行了輸出XML線槽WC3驗證的XML來驗證它是有效的。就像我之前說的,在FireFox 3.6中工作。我在Safari上嘗試過它,並且我得到了相同的「未定義」,所以它似乎與Webkit有關。
你能告訴我們xml是什麼樣子嗎? – Philippe 2010-03-10 13:00:40
編輯添加XML。 – Kitson 2010-03-11 15:33:48