Skip to content

Instantly share code, notes, and snippets.

@luislobo14rap
Created May 29, 2018 13:48
Show Gist options
  • Save luislobo14rap/c4d1c24420dbdc1e6f9b69294236426d to your computer and use it in GitHub Desktop.
Save luislobo14rap/c4d1c24420dbdc1e6f9b69294236426d to your computer and use it in GitHub Desktop.
// ajax-example.js v1
let obj = {
login: 'admin',
password: '1234'
};
ajax('submit.php', obj, function(status, data){
if(status){
}else{
};
});
// ajax.js v1
function ajax(url, obj, callback){
$.ajax({
url: url,
type: 'POST',
data: obj,
success: function(data){
if(data == 1){
// success
callback(true, data);
}else{
// error
callback(false, data);
};
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment