0

I try to run this code an a web browser to access the taleo API. I have already gotten the authToken by logging in. I now need to use it to make subsequent calls. However I get this error: Request header field authToken is not allowed by Access-Control-Allow-Headers. Can someone tell me the best way to actually do this?

xhr = $.ajax({
        type: "POST",
        url: logout,
        dataType: 'json',
        async: false ,
        crossDomain : true,
        headers: {'authToken': Token }, 
        success: function (data) {
        console.log(data);
        console.log(data.status.success)
        }
      });
bhspencer
  • 13,086
  • 5
  • 35
  • 44

1 Answers1

0

It seems you have cross domain issue. see below question for better explanation:

Cross domain AJAX call

Try this, you can set cross browser properties at client call also.

$.ajax({

        type:         "POST",
        url:          "test/test/test",
        dataType:     "text/xml",
        data:         "",
        processData:  false,       // default to true will parse data as an Array whereas we send XML
        contentType:  "text/xml",
        async:        false,
        beforeSend: function (request)
        {
            request.setRequestHeader("Access-Control-Allow-Origin", "*");
            request.setRequestHeader("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS");
            request.setRequestHeader("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With");
        },
Community
  • 1
  • 1
ChiranjeeviIT
  • 529
  • 1
  • 4
  • 17
  • Thank! Is it even possible to do this without changing anything server side? – shazeltion17 Sep 08 '15 at 01:50
  • Thank! I tried these and the error now give me: Request header field Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers. How can one get around this issue? – shazeltion17 Sep 08 '15 at 21:58