jQuery - 在iframe完成加载后将数据发布到iframe并重定向

Here is what I have so far:

<?php

// Simulating some post values for test proposes
$_POST['test'] = 'testing values';

// POST contents (originally from a form in another page)
$query = http_build_query( $_POST );

?>
<!DOCTYPE HTML>
<html>
<head>
 <meta http-equiv="content-type" content="text/html" />
 <script src="http://code.jquery.com/jquery-latest.js"></script>
 <script type="text/javascript">
  $(function() { $("#myiframe").load(function(){ window.location.replace('after.php'); }); });
 </script>
 <title>iFrame Load POST</title>
</head>
<body>
<iframe id="myiframe" src="load.php" width="0" height="0"></iframe>
</body>
</html>

What I need is to be able to send $_POST data, originally sent from a form in another page, to the iframe and redirect the page after the iframe has loaded and processed the post data.

---- EDIT ----

In fact, it doesn't need an iframe, but I still need to do a post call to load.php and wait for it to load in order to make the redirect. I cannot redirect before the load.php has finish loading the request. That's why I was using the iframe method and previously using GET instead of POST.

--------------

Can someone please help?

Thank you!

Just use a jQuery AJAX call. It allows you to attach a handler that gets executed once the request finishes successfully.

$.ajax({
    url: 'load.php',
    data: {foo: 'bar'},
    type: 'post', // you can use get if you want to.
    success: function(response) {
        window.location.replace('after.php'); 
    }
});