Question

I have a oauth secured rest (Sample)in my WSO2 ESB server.When i try to call from ajax , it shows cross domain issue.

my ajax call is :-

jQuery.ajax({
        beforeSend: function (request)
        {
            request.setRequestHeader("Authorization", "Bearer c791c67d8b272632d8e9e3ee9162179");
        },
        url: "http://192.168.1.27:8280/rest2",
        contentType :"application/x-www-form-urlencoded",
        type: "GET", 
        async: false,
        error: function (jq, status, message) {
            console.info('A jQuery error has occurred. Status: ' + status + ' - Message: ' + message+JSON.stringify(jq));

        },

        success: function() { 
        alert('Success!'); 
    }

    });

Does anybody have solution ? thanks

Was it helpful?

Solution

In this case, You have to add some cross domain headers to server response.

Required cross domain headers 1. Access-Control-Allow-Origin 2. Access-Control-Allow-Methods 3. Access-Control-Allow-Headers.

Thanks

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top