public
Last active

Sample code for executing an AJAX request using jQuery.

  • Download Gist
CorsRequest.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11
$.ajax({
url: 'MASHAPE-URL', // The URL to the API. You can get this by clicking on "Show CURL example" from an API profile
type: 'POST', // The HTTP Method
data: {}, // Additional parameters here
datatype: 'json',
success: function(data) { alert(JSON.stringify(data)); },
error: function(err) { alert(err); },
beforeSend: function(xhr) {
xhr.setRequestHeader("X-Mashape-Authorization", "YOUR-MASHAPE-KEY"); // Enter here your Mashape key
}
});

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.