0

Hi I am developing Angularjs application. I am trying to call post method but i am not able to call post method.

Below is my code.

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;
    }
});

Please find the screenshot here. Post issue

In request header i can see Request Method:OPTIONS but i made POST request? May i know am i doing anything wrong? Any help would be appreciated. Thank you.

0

2 Answers 2

0

I think problem isn't in your code - it's about CORS : there is more information : https://stackoverflow.com/a/12112294/6881115

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks. I have this error in console. Index.html:1 XMLHttpRequest cannot load paytabs.com/apiv2/validate_secret_key. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'localhost:10963' is therefore not allowed access.
Maybe try to use some proxy server in your project, like gulp-connect-proxy, grunt-connect-proxy ?
Okay. So to call other domain always i should use server?
0

Looks like you are making a cross domain request, angular code doesn't have any problem

3 Comments

Thanks. but how can i fix it?
Thanks. That dint work. i added some extension to chrome using below link. chrome.google.com/webstore/detail/allow-control-allow-origi/… May i know if this is the right way to fix this?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.