从javascript进行http调用时失败

Getting failure while making http call from javascript

本文关键字:失败 调用 http javascript 进行      更新时间:2023-09-26

我正在通过 GET 请求通过 http 访问网址。我正在使用下面的代码。

onReady: function() {
        var makeAjaxRequest = function() {

        var myUrl = encodeURI('http://domainname/VW-MAPP/fgnwasxuyu/10548168/2012-04-11 12:42:36/5555');
    Ext.Ajax.request({
        method: 'get',
    url:  myUrl,
    success: function(response)      {     
    alert(''+response.responseText);     
    console.log("response:-"+response.responseText);      },     
    failure: function (response)      {     
    console.log("Failure");    
    console.log("response status:-"+response.status);
    alert("Failure");
}
            });
        };

        new Ext.Panel({
            fullscreen: true,
            id: 'content',
            scroll: 'vertical',
            dockedItems: [{
                xtype: 'toolbar',
                dock: 'top',
                items: [{
                    text: 'XMLHTTP',
                    handler: makeAjaxRequest
                }]
            },{
                id: 'status',
                xtype: 'toolbar',
                dock: 'bottom',
                title: "Tap a button above."
            }]
        });
    }
});

我尝试了很多,但低于错误

XMLHttpRequest 无法加载//URLNAME//。访问控制允许原点不允许

源空。

如果有人有任何想法,请提供帮助。

谢谢

同源策略内置于浏览器中,可防止您对当前页面提供服务的域以外的任何其他域进行 AJAX 调用。

如果响应是 JSON,则可以使用 JSON-P 方法,否则需要服务器端代理来进行此调用。

我尝试了两种方法

(1(将响应.xml转储到本地域和访问,我们得到了成功。

(2(通过命令chrome禁用谷歌浏览器安全性.exe--allow-file-access-from-files --disable-web-security,并且能够通过GET方法点击url并获得成功。