I am working on a Scrabble question and to verify if the words exist in my language I am trying to use the wordreference api: http://www.wordreference.com/docs/api.aspx.
This is what kind of response it returns when accessing a word that doesn’t exist
1.
{
"Response" : "Redirect",
"URL" : "/enro/umbrella"
}
2.
{"Error" : "NoTranslation", "Note" : "No translation was found for umbrellaasd."}
My question is what do I put inside the success function below to see if the word exists or not?
function exista(word) {
var ok = 0;
var raspuns;
$.ajax({
async: false,
url: "http://api.wordreference.com/0.8/ff175/json/roen/" + word,
method: 'get',
success: function(transport) {
}
});
return ok;
}
Thank you! 🙂
transportis an object representing the server’s response, so you should be able to test fortransport.Errorand/ortransport.Responseto distinguish error and success responses.