Skip to content

Instantly share code, notes, and snippets.

@Wysie
Created May 23, 2014 02:35
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 Wysie/32b2f7276e4bd6acb66a to your computer and use it in GitHub Desktop.
Save Wysie/32b2f7276e4bd6acb66a to your computer and use it in GitHub Desktop.
AlchemyAPI jQuery API Call
//Hackish, using JSONP as JSON doesn't work. I wrote this portion for a Chrome extension and didn't see the need to host a server separately just to handle AlchemyAPI calls.
$.ajax({
url: 'https://access.alchemyapi.com/calls/text/TextGetTextSentiment',
dataType: 'jsonp',
jsonp: 'jsonp',
type: "post",
data: { apikey: 'APIKEYHERE', text: streamText, outputMode: 'json' },
success: function(res) {
if (res["status"] === "OK") {
//Do something good
}
else if (res["status"] === "ERROR") {
//Do something bad
}
},
error: function(jqxhr) {
//console.log(jqxhr);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment