title: How can I make an AJAX request and then remove the iframe the request was made from?
body: <p><strong>Background:</strong></p>
  
  <p>On my page there is an option to upload files, this opens an iframe that contains a form for uploading files. If the user decides to cancel the upload I want to make sure any files that were uploaded get deleted. So I make an ajax call to a jsp that runs a function to delete any temp files that were uploaded. After making the ajax call I remove the iframe from the screen so the user can continue their work. The jsp that deletes the files doesn't return anything and I don't need to let the user know that temp files were deleted.</p>
  
  <p>I found that this runs fine in IE but in chrome and safari an error is displayed to the user, after debugging for a while I found that the cause for the error was that the ajax call returns after the iframe is removed and chrome and safari don't like returning an ajax call to a removed iframe. So one solution is to make the ajax call synchronous. Another solution is to make the jsp spawn a thread to manage the delete. </p>
  
  <p><strong>Question:</strong></p>
  
  <p><em>What I'm wondering is if there is some way to modify the ajax call so it will return to a different page than the one that's getting removed?</em></p>
  
  <pre><code>function cancelAndDelete()
  {
      $.ajax({url:"removeTempFiles.jsp", data: {id: fileId}, async: true});
      $("#iframe").remove();
  }
  </code></pre>
  
  <p>Something like $(window.opener).ajax() doesn't seem to work but that's the idea I'm going for.</p>