Skip to content

Instantly share code, notes, and snippets.

Created March 25, 2012 06:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/2191714 to your computer and use it in GitHub Desktop.
Save anonymous/2191714 to your computer and use it in GitHub Desktop.
a guest on Mar 25th, 2012 - pastebin.com/gGkvgSfX
function myAjaxObject (){
this.varTo;
this.varFrom;
this.callbackfunctions = callbackfunctions;
this.callajax = callajax;
this.ajxmstrcl = ajxmstrcl;
this.settoandfrom = settoandfrom;
function settoandfrom(setUrlTo,setUrlFrom){
this.varTo = setUrlTo;
this.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){
this.ajxmstrcl(passtophppre+'Up','page='+pagestrng,'Up',truRL,clbksl2Dar[0],clbksl2Dar[1],clbksl2Dar[2]);
this.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
this.callbackfunctions(clb1ar);
$.ajax({ type: "POST", url: 'data/load_'+phpsuf+'.php', data: phpdataarg, dataType: "html",
success: function(msg){
if(parseInt(msg)!=0) {
this.callbackfunctions(clb2ar);
$('#pageContent'+loadtodiv).html(msg);
this.callbackfunctions(clb3ar);
}
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment