我已經設置了一個運行本地Web服務器(用ExtJs編寫)的Apache服務器。我也phantom.js提出並監聽8080端口塞康本地服務器:Ajax從本地js腳本調用本地Phantom.js服務器
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顯示正確的響應,所以服務器正常運行。
不同的端口將是一個與原點不同的域。 –
*此操作是否違反相同的原產地規定?*是*或者是其他內容?*是的。服務器正在報告400錯誤請求錯誤。 – Quentin
確定'錯誤請求'錯誤是否來自跨域問題? –