How would I call a function outside of my jQuery AJAX? I'm assuming I need to bind this
, but I'm not sure where or how many times.
mylib = {
do_the_ajax: function(data){
$.ajax({
url: "the_internet",
method: "DELETE",
data: JSON.stringify(data),
success: function() {
do_the_other_thing(); // How can I call this?
},
error: function() {
console.log("YOU FAIL!");
}
});
},
do_the_other_thing: function() {
console.log("WHAT THE FOX SAY");
}
}
I'm trying to call do_the_other_thing
inside do_the_ajax
. Inside do_the_ajax
, I could call this.do_the_other_thing()
, but I'm not sure how I would call that inside the ajax success
callback or what binding would be necessary.