When to consolidate methods - migrate
<p>Below are my 7 call back methods for ajax.  They are all similar in structure so that if I wanted I could abstract out the code into generic methods, call these generic methods, and modify them with input parameters/arguments.</p>

<p>However, I'm trying to determine the point at which consolidation is worth the effort.  Furthermore, what is considered best practice?</p>

<p>Shold I consolidate these methods?</p>

<pre><code>/*
consolidate these ajax call back functions
*/

function ajax_signup(a,b)
  {
  c=check_aml(a.slice(0,6));
  if(c===0)
    {
    document.f1_1.submit();  // on pass submit the file upload form
    }
  else if(c===1)
    {
    document.getElementById(b).innerHTML=a; // on fail report to user
    }
  else if(c===2)
    {
    a=a.substr(6);
    alert('php error: ' + a); // on php error
    }
  }

function ajax_signin(a,b)
  {
  c=check_aml(a.slice(0,6));
  if(c===0)
    {
    m6();  // on pass reload the page
    }
  else if(c===1)
    {
    document.getElementById(b).innerHTML='';  // on fail report to the user
    document.getElementById(b).innerHTML=a;  
    }
  else if(c===2)
    {
    a=a.substr(6);
    alert('php error: ' + a);  // on php error
    }
  }

/*
Takes in sturctured data and convert to xhtml - remove the conversion into another method
*/

function ajax_tweet(a,b)
  {
  var c,d,e,f='';
  var g=a.slice(0,6);  // prepare status
  var h=check_aml(g);  // check for status   
  if(h===0)
    {
    c=a.split(/\|\|/);
    for(e=0;e&lt;c.length;e++)
      {
      d=c[e].split(/\|/);
      f=f+'&lt;div class="Bb2b"&gt;&lt;img class="a" src="pictures/' + d[0] + '.jpg" alt=""/&gt;&lt;a class="a" href="javascript:void(0)\"&gt;' + d[1]  + ' posted ' + view_date(d[2],d[3]) + '&lt;/a&gt;&lt;br/&gt;&lt;p class="c"&gt;' + d[4] + '&lt;/p&gt;&lt;/div&gt;';
      }
    m2(b,f);
    }
  else if (h===1)    // on tweet fail - add in graceful fail &lt;xx_f&gt;
    {;}
  else if (h===2)
    {
    a=a.substr(6);
    alert('php error: ' + a);  // on php error 
    }
  }

/*
Ajax call-back methods - do nothing but report a PHP error if it ocurred.  On a success of and add or delete there is no message to the user.  Need to add in a graceful fail, ie. &lt;xx_f&gt;.
*/ 

function ajax_bookmark(a,b)
  {
  c=a.slice(0,6);
  d=check_aml(c);
  if(d===0)
    {;}
  else if (d===1)
    {;}
  else if (d===2)
    {
    a=a.substr(6);
    alert('php error: ' + a); 
    }
  }

function ajax_bookmark_add(a,b)
  {
  ajax_bookmark(a,b);
  }

function ajax_bookmark_delete(a,b)
  {
  ajax_bookmark(a,b);
  }

/*
Place holder for method parameter
*/  

function ajax_null()
  {
  }
</code></pre>
