title: Reading response text in Ajax using JQuery
body: <pre><code>function upload_file(){
      var file =document.getElementById('computer_image').files[0];
      if(file!==null){
          if(file.type==='image/jpeg' ||
              file.type==='image/png' ||file.type==='image/jpg'){
              $('#progressbar').show();
                          var formData = new FormData();
                          formData.append("file1", file);
                         $.ajax({
                              url: 'file_upload/ImageUpload', 
                              type: 'POST',
                              headers: {"abc": "aaaaaaaaa"},
                              xhr: function() {
                                  var myXhr = $.ajaxSettings.xhr();
                                  if(myXhr.upload){
       myXhr.upload.addEventListener('progress',progressHandler, false); 
                                  }
                                  return myXhr;
                              },
                              success: function( request,data, textstatus){
          alert(textstatus.getResponseHeader('abc'));
     },
                              error:errorHandler,
                              data: formData,
                              cache: false,
                              contentType: false,
                              processData: false
                          });
            }   
           else {
              alert('sorry we are not accepting file other than  PNG , JPEG and JPG');
           }  
      }
  }
  </code></pre>
  
  <p>I am using  CodeIgniter Framework .Below is my PHP code to Process a file . </p>
  
  <pre><code>function ImageUpload(){
      $status="";
      if (empty($_FILES["file1"]))
      {
          $status = "sorry Something went wrong";
          $this-&gt;output-&gt;set_status_header('400');
          echo "sorry Something went wrong";
      }
      if ($status !== "sorry Something went wrong")
      {
  
          //call a function to get path name
          $path="./upload";
          $config['upload_path'] = $path;
          $config['allowed_types'] = 'gif|jpg|png';
          $config['max_size' ] = '0';
          $config['max_width'] = '0';
          $config['max_height'] = '0';
          $config['remove_spaces']=TRUE;
          $config['overwrite']  = FALSE;
          $this-&gt;load-&gt;library('upload', $config);
          /* If directory doesn't exist than create a new .*/
          if (!file_exists($path) &amp;&amp; !is_dir($path)) {
                mkdir($path);         
          } 
          /* If there is any error during upload  */
          if ( ! $this-&gt;upload-&gt;do_upload('file1')){
              $this-&gt;output-&gt;set_status_header('400');
              echo "sorry Something went wrong";
          }   
           /*Image has been successfully Uploaded */
           else{
             $var = $this-&gt;upload-&gt;data('','');
                  echo $path.'/'.$var["file_name"].'='.$var["image_width"].
                   '='.$var["image_height"];
          }
  
       }
  </code></pre>
  
  <p>I have tried multiple flavor to get Response text but didn't success . What  should  be after complete to read response text .
  getting <code>null</code> as output .  </p>