title: ajax request finishes after redirect
body: <p>I have a problem with an ajax petition, I have a function as follows</p>
  
  <pre><code>function do_ajax (params, url, callback) {
      $.ajax({
          url: url,
          type: 'post',
          data: params,
          success: function (response){
              try{
                  var obj = $.parseJSON(response);
                  callback(obj);
              }catch(e){
                  alert('Cannot connect');
              }
          },
          error: function (jqXHR, textStatus, errorThrown){
              alert('err');
              console.log(jqXHR)
              console.log(textStatus)
              console.log(errorThrown)
          }
      });
  }
  </code></pre>
  
  <p>I call it with</p>
  
  <pre><code>function verificar_atenciones_paciente (p) {
      progress();
      do_ajax('', '&lt;?php echo base_url(); ?&gt;index.php/some/where/'+p.id, callback);
  }
  
  function callback (obj) {
      var table = $('#table tbody')
      var t = false;
      table.empty();
      if (0 == obj.length){ return; }
      $(obj).each(function (key, value){
          if (value.f){
              tiene = true;
          }else{
              alert('Redirect');
              window.location.href = '&lt;?php echo base_url(); ?&gt;index.php/some/where_else/'+value.id;
              return;
          }
          var tr = to_row(value);
          table.append(tr)
      })
      if (tiene_fac){
          alert("Found!");
      }else{
          alert("Not Found!")
      }
      $('#list').fadeIn();
      done();
  }
  </code></pre>
  
  <p>My problem comes when the redirection (<code>window.location.href = '&lt;?php echo base_url(); ?&gt;index.php/some/where_else/'+value.id;</code>) is called It executes some ajax in background and shows the error for the ajax request (<code>alert('Cannot connect');</code>).</p>
  
  <p>I am usign PHP, Code Igniter, JQuery.</p>
  
  <p>Thanks in advance</p>