Two responses coming when making a single ajax request to wit.ai

114 views Asked by At

When I am calling wit.ai I get two responses.

response 1:

Request Method:OPTIONS, Status Code:204 No Content, Response headers: Access-Control-Allow-Credentials:true Access-Control-Allow-Headers:Authorization, X-Requested-With, Content-Type, X-Wit-Instance.

response 2:

status code 200 post request all normal data required

function converse1(session_id){
  $.ajax({
    crossDomain: true,
    beforeSend: function (request){
      request.setRequestHeader('Authorization','Bearer YP2..');
    },
    url: 'https://api.wit.ai/converse?v=...&session_id='
         + session_id + '&q='+$("#msg").val(),
    method: 'POST',
    dataType: 'JSON',
    success: function() {
      console.log('1');
      console.log(request.responseText);
    },
    error: function() {
      console.log('failed')
    }
  });
}

therefore I am not able to capture the 2nd response data which was quite expected.Since the 1st response is failing, error block gets executed.If somehow i can capture data of 2nd response,then problem will be solved Thanks kindly help

0

There are 0 answers