我已经设置了一个本地运行的 Apache 服务器来托管我的 Web 应用程序(用 ExtJs 编写)。我还有一个用 phantom.js 制作的第二个本地服务器,并在端口 8080 上监听:
var server, service;
server = require('webserver').create();
service = server.listen(8080, function (request, response) {
response.statusCode = 200;
response.write('<html><body>Hello!</body></html>');
response.close();
});
现在我想从我的应用程序向幻像服务器发出 Ajax 请求:
Ext.Ajax.request({
url: 'http://localhost:8080',
method: 'GET',
success: function(response){
console.log('RESPONSE: ', response);
},
filure: function(response){
console.log('failure: ', response);
}
});
但是当运行这个脚本时,我得到:
"NetworkError: 400 Bad Request - http://localhost:8080/?_dc=1336648497292"
在控制台中。此操作是否违反同源策略?或者是别的什么 ?转到 localhost:8080 显示正确的响应,因此服务器运行正常。