title: error handling during ajax file upload using jquery form plugin
body: <p>i have a situation where i'm stuck at the idea of catching the appropriate error during file upload in the ajax response in jquery form-plugin.</p>
  
  <p>i'l give an idea of what i want to achieve through some pseudocode.</p>
  
  <p>My php is :</p>
  
  <pre><code> $file = strtolower($_FILES["myfile"]["name"]);
   $extension = substr($file, strrpos($file, '.') + 1);
   if($extension == 'jpg'){
    // upload the file
   if(move_uploaded_file($_FILES["myfile"]["tmp_name"], $folder . $finalFilename)){
    // do something here like
   echo "&lt;div id='statusContainer'&gt;
  &lt;table&gt;&lt;tr&gt;&lt;td&gt;
  &lt;img src='uploads/".$finalFilename."'&gt;
  &lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;".$finalts."&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
  &lt;/div&gt;";
         }
    } else {
    $error = 1; // will give numbers to different errors like filetype error, size error etc..
    }
  </code></pre>
  
  <p>now my JS code is :</p>
  
  <pre><code> (function() {
   var status = $('#status');   
   $('form').ajaxForm({
  complete: function(xhr) {
  if(xhr.responseText == "// what do i get echoed here so i can run an array and show user appropriate error like size error, type error etc. // "){
       // i want to open a dialog box with correct error message//
  } else{
      status.hide().html(xhr.responseText).fadeIn(1000);
      }
    }
     }); 
  
   })(); 
  </code></pre>
  
  <p>shall i get the error number echoed in the ajax response and run through an array to get the message? but then i'll have to put in a lot of if conditions in the ajax response with different error numbers. </p>
  
  <p>Please anyone have a more logical idea?? </p>