JSON Request: CORS Access-Control-Allow-Origin header error [duplicate]

-1

I need to make a JSON request for PayU, but it shows me the message:

  

Cross-origin request blocked: Same source policy (Same   Origin Policy) prevents the remote resource from being read   a a % 5D = 22222222 "> link .   (Reason: CORS 'Access-Control-Allow-Origin' header is not   present).

JS

    var data = {
        "test": false,
        "language": "en",
        "command": "PING",
        "merchant": {
            "apiLogin": "1111111",
            "apiKey": "22222222"
        }
    };

    $.ajax({
        url: "https://sandbox.api.payulatam.com/payments-api/4.0/service.cgi",
        method: 'GET',
        dataType:'json',
        headers: {
            'Content-Type': 'application/json',
        },
        data: data,
        success: function(data) {
            console.log('ok');

            console.log(data);
        }
    });

I tried to put the following code in the header, but it still does the same thing:

'Access-Control-Allow-Origin': '*'

I've tried other similar questions, but none helped.

    
asked by anonymous 18.06.2018 / 02:21

1 answer

1

I think this post below may help you

link

was given dataType: 'jsonp' , achieving success in this way.

    
18.06.2018 / 02:38