Skip to content

Instantly share code, notes, and snippets.

@galileoguzman
Created September 28, 2015 16:28
Show Gist options
  • Save galileoguzman/c0d06806b73777162152 to your computer and use it in GitHub Desktop.
Save galileoguzman/c0d06806b73777162152 to your computer and use it in GitHub Desktop.
Example how to use AJAX function on JQUERY
$.ajax({
type : 'POST',
url : 'http://localhost/api/get/all',
data : {'token': 'some string'},
dataType: 'JSON',
cache : false,
beforeSend : function(){
//Before to send request do a animation
// ...
},
error: function(request, status, error){
// If there is a error do something like show message
console.log(request.responseText);
},
success: function(response){
// If backend had to send you a response do something
// ...
console.log(response);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment