Internet Explorer CrossDomain请求无法正常工作,MS不会提供错误提示

问题描述 投票:0回答:1

我按照下面的Microsoft标准在请求中添加了变量,var openRetVal和var sendRetVal ...奇怪的是,它们没有得到返回的任何东西,所以Microsoft躺在自己的文档中吗?] >

我正在处理ajax请求,并且像往常一样,IE很难使用。我发现我可以执行XDR,而不是执行AJAX请求。我在chrome中的代码可以正常工作,因此我知道目标服务器正在运行,并且在成功请求后会执行预期的操作。以下是我的XDR代码段。

if ($.browser.msie && window.XDomainRequest) {
            var xdr = new XDomainRequest();
            //var webstring = location.protocol +"//"+ location.host +"/" + WEBSERVICE_URL + "/test";
            //WEBSERVICE_URL = "webservices/FormDesigner.svc";
            var webstring = WEBSERVICE_URL + "/test";
            var openRetVal = xdr.open("GET", webstring);  //added this var as it supposidly gets a return value from the function call.
            xdr.onload = function () {
                var JSON = $.parseJSON(xdr.responseText);
                if (JSON == null || typeof (JSON) == 'undefined') {
                    JSON = $.parseJSON(data.firstChild.textContent); 
                }
                //below is my onsuccess call which is called by both successes for IE and NON-IE processes allowing all stuff to be piped into 1 call.
                ajax_success(JSON);
            };
            xdr.ontimeout = function () {
                alert("XDR Error.  Timeout");
            }
            xdr.onerror = function () {
                alert("XDR Error.  Unable to do a Cross Domain Server Request.");
            };
            var sentRetVal = xdr.send();  //added this var as the function is suppose to return success or error as per microsoft.

        }

它总是返回错误,这自然不是我想要的。我暂时在同一域中对某些内容执行ping操作,以进行测试,这就是为什么没有其他内容的原因。就像我说的,到目前为止,它可以与其他浏览器一起使用...是否存在我不知道的格式错误?此测试请求也没有提交任何数据。

我按照下面的Microsoft标准在请求中添加了变量,var openRetVal和var sendRetVal ...奇怪的是,它们没有得到任何返回值,所以Microsoft躺在它们的......]

javascript ajax internet-explorer cross-domain
1个回答
3
投票
如果您使用jQuery

已经

,只需将jQuery用于所有浏览器
© www.soinside.com 2019 - 2024. All rights reserved.