1
我的服務託管在遠程服務器上,我在本地角js應用程序中使用服務。它在REST請求中工作正常,它不需要頭中的SessionID。當我在頭中添加會話ID時,它不起作用。給我404錯誤。404錯誤,當我通過會議ID在角度js發佈請求
app.factory( '主頁',函數($資源,$ HTTP){
return {
GetDashboardData : function(sessionid, id) {
alert(sessionid + '\n' + id);
var config = {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'SessionID': sessionid
}
};
return $http.post('url goes here'+id,config);
}
}
});
我修復了這個問題,因爲它是因爲跨域問題,我已經對REST API調用進行了更改,並且它現在可以工作 –
你可以在以下鏈接找到解決方案 http://stackoverflow.com/questions/15490256/why-does-a-cross-domain-angularjs-http-post-request-fail-when-a-xmlhttprequest http://stackoverflow.com/questions/19343316/angularjs-and-cross-domain-post – 2014-03-17 14:44:17
感謝Umair提供有用的鏈接。 –