Ajax 请求在 IE 8 中似乎失败

Ajax request seems to fail in IE 8

本文关键字:失败 请求 IE Ajax      更新时间:2023-09-26

以下jQuery代码从Met Office数据点返回一个xml文件,并应使用xml数据中的属性提醒用户:

$.ajax({
            url: "http://datapoint.metoffice.gov.uk/public/data/val/wxfcs/all/xml/324246?res=daily&key=myapikey",
            dataType: "xml",
            method: "GET",
            success: function (text) {
                myValue = $(text).find("Period Rep").first().attr("W");
                alert(myValue);
            },
            error: function () {
                alert("Not working");
            }
        })

这在 Chrome 中运行良好,并且符合我的预期,但在 IE8 中调用了错误函数。 知道我做错了什么或为什么IE不想工作吗?

(注意:我知道IE8远非理想,但不幸的是,我必须为此应用程序支持它。 目前没有办法解决这个问题)

试试

jQuery.support.cors = true;

在请求之前和

crossDomain: true

作为 AJAX 选项