I have the following working example, I'm trying to get http://detectlanguage.com via a jquery request. Since this will be a cross-domain request I'm using jsonp.
Here is a link in MSDN with a similar request where it's infered that jsonp
is the way to go.
Everything's fine, except the page throws an error Error: myCallback was not called
, the response I get from server is the following:
{"data":
{"detections":[
{"language":"ca",
"isReliable":false,
"confidence":0.14992503748125938
},
{"language":"en",
"isReliable":false,
"confidence":0.00 8103727714748784
}]
}
}
I've been searching all day in stackoverflow for answers regarding jsonp but haven't got it to work yet.
Any help is very much appreciated
UPDATED
Including AJAX call
$.ajax({
url: 'http://ws.detectlanguage.com/0.2/detect',
data: {
q: $('#hi').val(),
key:'demo'
},
jsonpCallback: 'myCallback',
dataType: "jsonp",
success: myCallback,
error: function(e,i,j){
$('#results').html(j)
}
});
I also have a javascript function called myCallback
:
function myCallback(response){
alert(response.data)
}