I am trying to call API through below code. but my browsers are giving the same error and no response is getting from server.
And my API is working fine I have tested through postman. I dont know where I am getting wrong
I have also tried to put some header content type
application/json, application/x-javascript , application/javascript, text/json
function send(text) {
$.ajax({
url: 'http://localhost:5005/conversations/default/respond',
type: 'POST',
dataType:'jsonp',
headers: {
'Content-Type': 'application/javascript'
},
data: //JSON.stringify({
{
"q": text
},//),
success: function (data, textStatus, xhr) {
console.log(data);
if (Object.keys(data).length !== 0) {
for (i = 0; i < Object.keys(data[0]).length; i++) {
if (Object.keys(data[0])[i] == "buttons") { //check if buttons(suggestions) are present.
addSuggestion(data[0]["buttons"])
}
}
}
setBotResponse(data);
},
error: function (xhr, textStatus, errorThrown) {
console.log('Error in Operation');
setBotResponse('error');
}
});