我正在开发一个需要CORS的应用程序,我做了一些google,但无法理解。当我向localhost:9090发出ajax请求时,我的应用程序运行在localhost:8000上。下面是我的Ajax请求代码..。
Ext.Ajax.request({
url : 'http://localhost:9090/by-api',
method: 'POST',
jsonData : api_no,
disableCaching: false,
withCredentials: true,
useDefaultXhrHeader: false,
headers: {
"Content-Type":"text/plain",
'Access-Control-Allow-Orgin':'*',
'Access-Control-Headers': 'x-requested-with'
},
success: function(response){
console.log(response.responseText)
},
failure: function(response){
console.log(response.responseText)
}
});
此外,我还想做一个基本的身份验证,所以我试着把‘身份验证’放在标题中,但是没有任何东西起作用。
发布于 2013-09-14 09:30:01
指令
'Access-Control-Allow-Orgin':'*'
必须在响应头中包括服务器端,而不是在客户端请求中。按照此文档引用W3-CORS
https://stackoverflow.com/questions/18785475
复制相似问题