Alright, I'm trying to get form values via jQuery serialize
. Here's my jQuery code.
$("#add_cus_button").click(function(e){
e.preventDefault();
//
$.ajax({
type: 'POST',
url:'ajax.php?requestid=14',
data:{postdata:$("form#addnew").serialize()},
success: function(response)
{
}
})
});
Here's my PHP :-
$postdata = explode('&', $_POST['postdata']);
var_dump($postdata);
This results into this :-
Now if I try to access a field called customer_name
, I do this.
echo $postdata['requestid'];
But this throws undefined index error. How do I overcome this?