嗨我正在開發Angularjs應用程序。我正在嘗試調用post方法,但我無法調用post方法。如何在Angularjs中調用post方法?
以下是我的代碼。
app.service("payementservice", function ($http) {
this.makepayment = function() {
debugger;
var validatesecretekeyData = {
merchant_email: "",//some data
secret_key: ""//somedata
};
var validatesecretekeyUrl = "https://www.paytabs.com/apiv2/validate_secret_key";
var responseservice = $http.post(validatesecretekeyUrl, validatesecretekeyData).success(function (response) {
});
return responseservice;
}
});
在請求頭我可以看到請求方法:選項,但我提出了POST請求?我可以知道我做錯了什麼嗎?任何幫助,將不勝感激。謝謝。
謝謝。我在控制檯中有這個錯誤。 Index.html:1 XMLHttpRequest無法加載https://www.paytabs.com/apiv2/validate_secret_key。對預檢請求的響應不會通過訪問控制檢查:請求的資源上不存在「Access-Control-Allow-Origin」標頭。原因'http:// localhost:10963'因此不被允許訪問。 –
也許嘗試在你的項目中使用一些代理服務器,如gulp-connect-proxy,grunt-connect-proxy? – dasiekjs
好的。所以要打電話給其他域我總是應該使用服務器? –