[英]Sencha Touch - Cross Domain (CORS) Issue
I am attempting to load datapoints from a cross domain URL. 我正在尝试从跨域URL加载数据点。 Unfortunately I can't get this to work.
不幸的是我无法使它正常工作。 I have set up my Apache Linux server to support CORS as far as I can tell.
据我所知,我已经设置了Apache Linux服务器以支持CORS。 I added the following to the header of the configuration file:
我将以下内容添加到配置文件的标题中:
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET,POST"
Header set Access-Control-Allow-Headers "X-Requested-With"
This is the current setup of my store: 这是我商店的当前设置:
var myStore = Ext.create('Ext.data.Store',
{
fields: [{name: 'xTime', type: 'int'}, {name: 'yData', type: 'float'}, {name: 'target', type: 'string'}],
proxy:
{
type: 'ajax',
url: 'http://test.com/datapoints.json',
useDefaultXhrHeader: false,
reader: 'points'
},
autoLoad: true
});
I'm just trying to find what am I missing here? 我只是想找到我在这里想念的东西吗? I'm testing it using Safari and so far, I'm still getting the "Access-Control-Allow-Origin" error.
我正在使用Safari对其进行测试,到目前为止,我仍然收到“ Access-Control-Allow-Origin”错误。
Any help would be greatly appreciated! 任何帮助将不胜感激!
Can you set up a packet sniffer such as WireShark to see the actual HTTP request being sent to the server. 您是否可以设置数据包嗅探器(例如WireShark)以查看实际的HTTP请求被发送到服务器。 Or alternatively, configure your server to log the request/response headers.
或者,将您的服务器配置为记录请求/响应标头。 My guess is either that the request doesn't include the Origin header, or the request includes some other request header that isn't included in the Access-Control-Allow-Headers method.
我的猜测是请求不包含Origin标头,或者请求包含Access-Control-Allow-Headers方法中不包含的其他请求标头。 One thought, try adding Content-Type to the Access-Control-Allow-Headers method;
一种想法,尝试将Content-Type添加到Access-Control-Allow-Headers方法; this is a common one that is needed when requesting JSON data.
这是请求JSON数据时需要的一种常见方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.