Skip to content

Instantly share code, notes, and snippets.

@kim-codes
Last active December 1, 2016 07:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kim-codes/3287c5b82e846676836298044c3ee2a1 to your computer and use it in GitHub Desktop.
Save kim-codes/3287c5b82e846676836298044c3ee2a1 to your computer and use it in GitHub Desktop.
data = null;
xhr = null;
xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
jsonText = JSON.parse(xhr.responseText);
wordDefinition = jsonText.results[0].lexicalEntries[0].entries[0].senses[0].subsenses[0].definitions[0];
console.log(jsonText.results[0].lexicalEntries[0].entries[0].senses[0].subsenses[0].definitions[0]);
}
});
xhr.open("GET", "https://od-api.oxforddictionaries.com:443/api/v1/entries/en/"+wordToSearch+'/definitions', false);
xhr.setRequestHeader("accept", "application/json");
xhr.setRequestHeader("app_id", "xxxx");
xhr.setRequestHeader("app_key", "xxxx");
xhr.send(data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment