Created
February 15, 2019 01:23
-
-
Save silverwolfceh/02a3b602e8befa52065d2035a8471270 to your computer and use it in GitHub Desktop.
UTF8 Json parse javascript demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function en2vi_trans(word) | |
{ | |
var k = "trnsl.1.1.20190214T041113Z.bc4d15cca572abd8.xxxxxxxxxxxxxxxxxxxxxxxxxxxx"; //YANDEX API KEY, FREE | |
var url = "https://translate.yandex.net/api/v1.5/tr.json/translate?key=" + k + "&lang=en-vi&text=" + word; | |
return $.get(url, function(data) { | |
console.log(data); | |
info = JSON && JSON.parse(JSON.stringify(data)) || $.parseJSON(JSON.stringify(data)); | |
if(info.code == 200) | |
{ | |
var t = "Meaning of: " + word+ " is " + info.text[0]; | |
alert(t); | |
return info.text[0]; | |
} | |
else | |
return "Unavailable"; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment