我用GET请求在http上点击了一个url。我正在使用下面的代码。
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//。Access-Control-Allow-Origin不允许Origin为空。
如果任何人有任何想法,请帮助。
谢谢
发布于 2012-05-17 14:28:23
我尝试了两种方法
(1)将response.xml转储到本地域并访问,成功。
(2)通过命令chrome.exe --allow-file-access-from-files -- Disable -web-security禁用google chrome安全性,并能够通过GET方法命中url并获得成功。
发布于 2012-05-17 13:39:59
AJAX同源策略内置于浏览器中,可防止您对除提供当前页面的域之外的任何其他域进行调用。
如果响应是JSON,您可以使用JSON-P方法,否则您需要一个服务器端代理来进行此调用。
https://stackoverflow.com/questions/10636816
复制相似问题