First time I've attempted to use serialize data. On my main page when the submit button is clicked I'm running :
$.ajax({
url:'test.php?add=1',
data:$(this).serialize(),
type:'POST' })
.done(function(data) {
console.log(data);
})
On the test page I have :
if (isset($_REQUEST['add']) && $_REQUEST['add'] == '1' ) {
var_dump($_REQUEST);
}
When I submit the form, all I get back in the console is:
array(2) {
["add"]=>
string(1) "1"
["PHPSESSID"]=>
string(32) "a9005002332f548a0c85b06402dfae12"
}
My form has about 30 fields, I thought I'd get the name and value of each field. eg: field1=value1&field2=value2&field3=value3
Normally when I've done this I've used:
url:'test.php?add=1&field1=' + field1 + '&field2=' + field2,
etc.. which does return this data.
How do I get the values of the submitted data when using serialize ?
Thanks
$.ajax({
type:"POST",
url:'test.php',
data:$("#myForm").serialize(),
success: function(response){
console.log(response);
}
});
//on php page get data
if(isset($_POST)){ var_dump($_POST); }