简体   繁体   English

jquery ajax 请求在 IE6 中失败

[英]jquery ajax request failing in IE6

I have got a ajax request working in safari,FF and Chrome but not in IE6.I get the error message and the xhr.statusText is unknown .I know I should be ditching IE6 but its in the requirements list so I'm helpless.If anyone has a solution to please lemme know.我有一个 ajax 请求在 safari、FF 和 Chrome 中工作,但在 IE6 中没有。我收到错误消息,xhr.statusText未知。我知道我应该放弃 IE6,但它在要求列表中,所以我无能为力。如果有人有解决方案请让我知道。

Thanks谢谢

$.ajax({
        type: "GET",
        url: "vMenu.xml",
        dataType: "xml",
        error:function(xhr, status, errorThrown) {
                alert(errorThrown+'\n'+status+'\n'+xhr.statusText);
        },
        success: function(data) {
            alert('success')        ;
        }
    });

the XML file XML 文件

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="vMenu.xsl"?>
<vMenuList>
    <menu loc="menu1.htm">menu1</menu>
    <menu loc="menu2.htm">menu2</menu>  
    <menu loc="menu3.htm">menu3</menu>  
    <menu loc="menu4.htm">menu4</menu>  
    <menu loc="menu5.htm">menu5</menu>  
    <menu loc="menu6.htm">menu6</menu>  
    <menu loc="menu7.htm">menu7</menu>  
    <menu loc="menu8.htm">menu8</menu>  
</vMenuList>

All the files are in the same folder所有文件都在同一个文件夹中

Try replacing the success with complete:尝试用完成替换成功:

$.ajax({
        type: "GET",
        url: "vMenu.xml",
        dataType: "xml",
        error:function(xhr, status, errorThrown) {
                alert(errorThrown+'\n'+status+'\n'+xhr.statusText);
        },
        complete: function(data){
            alert('success');
        }
});

That should do the trick.这应该够了吧。 For more info on why this occurs: http://api.jquery.com/jQuery.ajax/有关为什么会发生这种情况的更多信息: http://api.jquery.com/jQuery.ajax/

Does your server send the appropriate "text/xml" content type header?您的服务器是否发送适当的“文本/xml”内容类型 header?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM