作者ayaun (拖油瓶的无奈)
看板Ajax
标题[问题]处理responseXML
时间Tue Apr 15 20:51:11 2008
我在SVG档案里面使用 javascript (ecmascript) 发出HttpRequest
伺服器端用 php取MySQL资料 写成XML档案 回传 (严格来说是SVG档案)
<问题一>
在php中 header 需设为 header("Content-Type: text/xml")
若设为 header("Content-Type: image/svg+xml") 回传的responseXML会没有物件
小弟不晓得问题在哪 希望有高手能为我讲解
<问题二>在处理responseXML 部分
<script type="text/ecmascript"><![CDATA[
..............
var svgDoc = xmlHttp.responseXML; // reponseXML
var importedNode = document.importNode(svgDoc.documentElement,true);
var oldMap = document.getElementById("mainMap");
oldMap.appendChild(importedNode);
.............
]]></script>
直接alert(svgDoc.documentElement.xml) 档案是正确的
但是在 importNode(svgDoc.documentElement,true) 就出现错误
IE的 错误讯息为 "型态不符合" 一值找不到解决方法
希望有大家帮忙解决 或是 提供点意见
thanks!
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.121.130.197
1F:→ ayaun:reponseXML 只能接受 Content-Type: text/xml 04/18 16:51
2F:→ ayaun:只是对 Content-Type 设定还是不是很懂 04/18 16:52
3F:→ ayaun:问题二 应该是接收到SVG档案格式问题 04/18 16:54
4F:→ ayaun:只好自己写function 把资料加进去 只是可能方法比较笨 04/18 16:57