Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用jQuery读取XML在ie6和ie8中不起作用_Jquery_Xml_Internet Explorer_Parsing - Fatal编程技术网

使用jQuery读取XML在ie6和ie8中不起作用

使用jQuery读取XML在ie6和ie8中不起作用,jquery,xml,internet-explorer,parsing,Jquery,Xml,Internet Explorer,Parsing,使用jQuery读取XML在ie6和ie8中不起作用。我使用了下面的代码。。该警报不会出现在ie8、ie6中,我还没有使用其他internet explorer版本进行测试 $(document).ready(function() { $.ajax({ type: "GET", url: "xml/contextMenu.xml", dataType: "xml", success: function(xml) {

使用jQuery读取XML在ie6和ie8中不起作用。我使用了下面的代码。。该警报不会出现在ie8、ie6中,我还没有使用其他internet explorer版本进行测试

$(document).ready(function()
{
    $.ajax({
        type: "GET",
        url: "xml/contextMenu.xml",
        dataType: "xml",
        success: function(xml) {
            alert('hi');            
        }
    });
});
但是它在mozilla Firefox3.6.3中起作用。 任何人都知道可能是什么问题。。。
请帮助我…

在开始使用$.ajax()语句之前,请先尝试一下

函数parseXML(xml){
如果(jQuery.browser.msie){
var xmlDoc=newActiveXObject(“Microsoft.XMLDOM”);
加载xml(xml);
xml=xmlDoc;
}
返回xml;
}

然后,在成功中,添加: var newXML=parseXML(xml)


将xml引用更改为newXML,您应该会很好。

IE 6-8无法正确读取mime类型,因此您将其作为文本文件传递,然后使用函数.parseXML将其转换为xml文件

  $(document).ready(function() {  
 $.ajax({
    type: "GET",
    url: "menu.xml",
    dataType:"text",
    success: selectXml
});
   function selectXml (xml) {
   alert('hello');
  }
这对我有用

function text2XML(txt) { var xmlDoc; if (window.DOMParser) { xmlDoc=(new DOMParser()).parseFromString(txt,"text/xml"); } else { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async="false"; xmlDoc.loadXML(txt); } return xmlDoc; } 函数text2XML(txt) { var-xmlDoc; if(window.DOMParser) { xmlDoc=(新的DOMParser()).parseFromString(txt,“text/xml”); } 其他的 { xmlDoc=新的ActiveXObject(“Microsoft.XMLDOM”); xmlDoc.async=“false”; xmlDoc.loadXML(txt); } 返回xmlDoc; }
如果将错误处理程序添加到jQueryAjax调用中,会发生什么?它显示了什么吗?