【问题标题】:Windows 8/IE10 Not working with $.ajax GetWindows 8/IE10 不使用 $.ajax 获取
【发布时间】:2013-05-24 12:24:28
【问题描述】:

所以工作是将所有机器升级到 Windows 8,我们遇到了兼容性问题。这适用于除 Windows 8 以外的所有浏览器。

所有这些脚本都在 windows server 2008 上运行,所以我知道为什么 IE10 会出现问题:

function getProject(type, number){

            $.ajax({
                type: "GET",
                cache: false,
                url: "prospect.xml",
                dataType: "xml",
                complete: function(XMLHttpRequest, textStatus){
                            if (textStatus!='success') {
                                $('#column-left').hide()
                                $('#column-right').hide()
                                $('#error').html('There was an error loading the data, please contact Systems Management').show()
                            }
                        },
                success: function (data) {                      
                        if (type=='all') {                          
                            parseXmlAllProjects(data)
                        } else if (type='specific') {
                            parseXmlSpecificProject(data, number)
                        }
                    }
              });             

        }

由于某种原因,该脚本无法检查 textStatus,它没有成功加载 xml 文件。像这样在我们的 winxp 环境中运行得非常好。

有什么想法吗?

【问题讨论】:

  • 我不确定操作系统是你的问题,因为 Windows 8 和 IE10 上的 JQuery 对我来说工作得很好。乍一看,我在您的陈述中也找不到错误,也许是其他问题?
  • 尝试在ajax错误函数中记录错误
  • 是的,我已经测试了很多其他使用 jquery 的应用程序,甚至是与上述类似的 jquery 应用程序,它们都运行良好..它让我感到厌烦
  • 只是为了检查一下——如果你将浏览器置于兼容模式(对 IE9 来说)它可以工作吗?
  • 我检查了兼容性。 IE9 不工作 IE10 不工作,但 IE8 及以下都工作。

标签: php jquery ajax xmlhttprequest


【解决方案1】:

尝试更改此行:

complete: function(XMLHttpRequest, textStatus){

到这里:

complete: function(jqXHR, textStatus){

我猜 IE10 不喜欢你使用 XMLHttpRequest 名称。

【讨论】:

  • 我做了更改但没有任何效果。
【解决方案2】:

在阅读了一些文章后,我发现由于 IE9 IE 不会像以前版本的 IE 那样返回 msxml 文档。因此代码已更改为以下内容:

函数getProject(类型,数字){

            $.ajax({
                    type: "GET",
                cache: false,
                url: "prospect.xml",
                dataType: ($.browser.msie) ? "text" : "xml", 
                beforeSend: function(xhr, settings){
                   try {xhr.responseType = "msxml-document";} catch(err){}
                   },

                                    success: function (data) {      
                        if (type=='all') {                          
                            parseXmlAllProjects(data)
                        } else if (type='specific') {
                            parseXmlSpecificProject(data, number)
                        }
                    }
              });                           
        }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-01-12
    • 1970-01-01
    • 1970-01-01
    • 2013-06-18
    • 1970-01-01
    • 1970-01-01
    • 2014-03-21
    相关资源
    最近更新 更多