I use this jQuery Ajax-Request, which I configured for my needs:
jQuery.ajax({
url: "apiBridge.php?url=" + encodeURIComponent(url),
headers: {
"Some Weird Header": "123"
},
success: function(data){
},
complete: function(){
doAlotOfStuff();
andMore();
}
});
The real code is fairly lengthy and I consider it stupid to copy/paste the whole thing every time I need to make an Ajax-request in my style.
What I want to do, is to define this function once, so I am able to re-use it. All I need to change for each instace of the function is the url and success callback.
What is the right way to do this?