很簡單的段$http.get向接口請求數(shù)據(jù)的方法。但是就是不知道什么原因,一直提示無法跨域。請問該怎么解決?(PS:在另外一個頁面加入API_HOST_URL后,post值到那個路徑,沒有報(bào)過任何無法跨域的報(bào)錯,但是同樣的復(fù)制過來,在get方法下卻不管用)functiontogetpNo($scope,$http){vararray=$scope.array;$http.get(API_HOST_URL+'/ss/test.do?pNo='+array).success(function(data){alert(data);}).error(function(e){alert('請求失敗了');})}報(bào)錯內(nèi)容:XMLHttpRequestcannotloadhttp://datatest.dev:8081/ss/test.do?pNo=h01,h02.No'Access-Control-Allow-Origin'headerispresentontherequestedresource.Origin'http://localhost:8080'isthereforenotallowedaccess.改成用jsonp寫:$http.jsonp(API_HOST_URL+"/ss/test.do?jsonp=JSON_CALLBACK&pNo="+array)報(bào)錯:UncaughtSyntaxError:Unexpectedtoken:
angularjs $http.get無法跨域問題
回首憶惘然
2019-04-19 16:11:37