I want to read all the mail variables and their contents from the form and publish them using jquery "$ .post ()". First of all, this will not work: $ .post ("myServer.com/test2.php", $ ('# myform'). Serialize ()) because it would send only one variable that I would have to parse on the php side .
Here's how I started:
function doIndirectPost() { variableWithTheFormPOSTData = {}; $("#IdOfMyForm :input").each(function() { variableWithTheFormPOSTData[$(this).attr("name")] = $(this).attr("value"); } document.getElementById("IdOfMyForm").submit(); $.post("myServer.com/test2.php", variableWithTheFormPOSTData); }
and then I would like to use $ .post () to publish data separated by several variables (just like the normal submit form would do this ... I read somewhere that you can do it like this:
$.post('myserver.com/test2.php.php',{ var1: content1, var2: content2 }
But I want it to be dynamic. This part:
var1: content1, var2: content2
should automatically contain all variable names and form values.
In the end, I would like to get all the POST variables as follows:
foreach ($_POST as $key => $value) { echo $key . "= " . $value; }
source share