如何使用javascript重新发布带有GET参数的数据(构建并附加html表单然后提交)

How to I re-POST data with GET parameters with javascript? (build and append html form and then submit it)

<?php
if($_POST){
    print_r($_POST);
    die();
}
?>

<script>
    //code here to create form, based on GET arguments
    form.submit();
</script>

and page url would be called with many diffrent get arguments like

?a=b&b=c ?ddd=eee&fff=ccc

(only pure js, no jquery or other js frameworks)

use the FormData object of javascript and a formData.append() for every field you get from the $_POST;

Example:

var formData = new FormData(form)
<?php
    foreach($_POST as $key => $value) {
        echo "formData.append({$key}, {$value});";
    }
?>
// and then just submit the form...

I am not sure if I fully understood you, but here's what I consider to be helpful for you atm. To keep it simple, I assume you have no array children in your GET object. This is possible but makes the code a bit longer and I am short on time right now.

This resends GET data as POST data.

<form id="repost" method="post" action="/target.php">
<?php
   foreach ($_GET as $key => $val)
   {
      // ADD VALIDATIONS AND
      // XSS INJECTION PROTECTION HERE, 
      // E.G. $val = str_replace('"',"'",$val);
      ?><input type="hidden" name="<?=($key)?>" value="<?=($val)?>"><?php
   }
?>
</form>
<script>document.getElementById("repost").submit();</script>