title: Redirect in the middle of an ajax request
body: <p>I have a site where users can publish links. Users fill a form with 2 fields:</p>
  
  <ul>
  <li>Title </li>
  <li>URL</li>
  </ul>
  
  <p>When the user clicks "submit" I have a crawler that looks for an image of the link provided and makes a thumbnail.</p>
  
  <p>The problem is that <strong>the crawler usually takes about 5-10 seconds to finish loading</strong> and cropping the thumb.</p>
  
  <p>I thought I could do an ajax call like this. As you can see, when the user submits a link first we see if its valid (first ajax call) then if succesful we do another ajax call to try to find and save the image of this link.</p>
  
  <p>My idea was to do that while I move the user to the links.php page, however, I find that if I do it like this the AJAX call breaks and the function in <code>save_image.php</code> doesn't run.</p>
  
  <p>What can I do to avoid making my users wait for the <code>save_image.php</code> process? I need this process to run, but I don't need any data returned.</p>
  
  <pre><code>$.ajax({
                      url: 'publish/submit_link.php',
                      type: 'POST',
                      dataType: 'JSON',
                      data: {
                          link            : link,
                          title           : title,
                      },
                      success: function (data) {
                          if (data) 
                          {
                              $.ajax({
                                  url: 'publish/save_image.php',                                      type: 'POST',
                                  data: {
                                          id              : data.id,
                                          type            : data.type,
                                      url             : url,
                                          csrf_test_name  : csrf
                                  }
                              });
                          }
  
                          //THIS NEXT LINE BREAKS SECOND AJAX CALL
                          window.location = 'links.php';
  
                      }   
  });
  </code></pre>
  
  <p>Thanks in advance!</p>
  
  <p><strong>SUMMING UP:</strong> I want the user to submit a link and redirect the user to the links page <strong>while the thumbnail for that link is being generated</strong>. I don't want to show the thumbnail to the user.</p>