我在Dojo中使用dojo.xhrPost方法,並嘗試從不同的域服務器REST服務調用url。我在跨領域面臨問題。Dojo中使用Ajax的跨域REST
我已經得到錯誤:::「RequestError:無法加載https://core.dev.moxynetwork.com/rest/authservice/authuser狀態:0」
請幫助我。
問候&感謝, Vijayalaxmi
我在Dojo中使用dojo.xhrPost方法,並嘗試從不同的域服務器REST服務調用url。我在跨領域面臨問題。Dojo中使用Ajax的跨域REST
我已經得到錯誤:::「RequestError:無法加載https://core.dev.moxynetwork.com/rest/authservice/authuser狀態:0」
請幫助我。
問候&感謝, Vijayalaxmi
您需要實現JSONP或Cross-Origin Resource Sharing(CORS)管理跨域調用。兩者都是REST API的技術,在客戶端無法做到。
dojo.xhrPost已棄用,且將被移除。
使用Dojo /請求/腳本道場1.9:
require(['dojo','dojo/ready','dojo/_base/lang','dojo/_base/array', 'dojo/request/script' ],
function(dojo, ready, lang, array,script){
ready(function(){
request.get('ENTER-YOUR-URL.com',{jsonp: "callback"}).then(function(resJson){
console.log(resJson);
});
});
});