Created
December 19, 2019 16:55
-
-
Save BMU-Verlag/71ea262b00c46aef5e544d8455bcf693 to your computer and use it in GitHub Desktop.
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 translateText() { | |
var input = document.getElementById("input").value; | |
var languages = document.getElementById("source_language").value + "-" + document.getElementById("target_language").value; | |
var url = "https://translate.yandex.net/api/v1.5/tr.json/translate?key=<API-key>&text=" + input + "&lang=" + languages; | |
var xhttp = new XMLHttpRequest(); | |
xhttp.onreadystatechange = function() { | |
if (this.readyState == 4 && this.status == 200) { | |
document.getElementById("translated_text").value = JSON.parse(this.responseText)["text"][0]; | |
} | |
}; | |
xhttp.open("POST", url, true); | |
xhttp.send(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment