Skip to content

Instantly share code, notes, and snippets.

@boxxxie
Forked from anonymous/gGkvgSfX
Created March 25, 2012 06:20
Show Gist options
  • Save boxxxie/2191747 to your computer and use it in GitHub Desktop.
Save boxxxie/2191747 to your computer and use it in GitHub Desktop.
a guest on Mar 25th, 2012 - pastebin.com/gGkvgSfX
function myAjaxObject (){
var varTo;
var varFrom;
var callbackfunctions = callbackfunctions;
var callajax = callajax;
var ajxmstrcl = ajxmstrcl;
var settoandfrom = settoandfrom;
function settoandfrom(setUrlTo,setUrlFrom){
varTo = setUrlTo;
varFrom = setUrlFrom;
}
function callbackfunctions(whichcallbacks){ //maybe accept an array of numbers and do foreach)
if(whichcallbacks.length===0) return 0; ///correctly check if it's empty?
else{
var todofunc = whichcallbacks.shift();
switch(todofunc){ //use this.callbackfunctions(whichcallbacks);
case (0):
case (0):
case (0):
case (0):
case (0):
default: alert('callbackinajaxDNE');
}
}
}
function callajax(passtophppre,pagestrng,truRL,clbksl2Dar){
ajxmstrcl(passtophppre+'Up','page='+pagestrng,'Up',truRL,clbksl2Dar[0],clbksl2Dar[1],clbksl2Dar[2]);
ajxmstrcl(passtophppre+'Low','page='+pagestrng,'Low',truRL,clbksl2Dar[3],clbksl2Dar[4],clbksl2Dar[5]);
}
function ajxmstrcl(phpsuf,phpdataarg,loadtodiv,truU,clb1ar,clb2ar,clb3ar){ //can you pass null arguments? ///can really make this better if i use hashes for URLs, and if i dont can just change var names
callbackfunctions(clb1ar);
$.ajax({ type: "POST", url: 'data/load_'+phpsuf+'.php', data: phpdataarg, dataType: "html",
success: function(msg){
if(parseInt(msg)!=0) {
callbackfunctions.forEach(function(fn){
fn(clb2ar);
});
$('#pageContent'+loadtodiv).html(msg);
callbackfunctions(clb3ar);
}
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment