I’m trying to post an array to another file to be processed. The array is below and it populates rows properly. I have it initialized at the beginning of the script tag to make it global.
In javascript:
var locationsall = new Array();
locationsall[counter] = new Array();
locationsall[counter][0] = address;
locationsall[counter][1] = lat;
locationsall[counter][2] = lng;
In my form i try to serialzie it and post it
<input type="hidden" name="result" value="<?php echo serialize($locationsall); ?>">
When i try to unserialize it, it doesn’t have anything..
$locations = unserialize($_POST['result']);
What am i doing wrong here?
When you are updating client-side data via jQuery, you need to set the value of result to whatever it is that you want to pass through. You can serialize a JS object using jQuery.param(), so you can then pass through JSON-encoded data to PHP. When processing the post data you would then need to decode the JSON data in
$_POST['result']JS
PHP