I am using AJAX to submit a form, and would like to display a summary of the information on the page so that the user can confirm the information before submitting. I am hav
Generally you want to use json_encode
on arrays. So your PHP array would look like:
$arr = array('foo' => 1, 'bar' => 2, 'baz' => 'test');
// you can probably just use $_POST here, i.e. $arr = $_POST
echo json_encode($arr);
And your JavaScript dealing with that data
variable would look like this:
$('#id').html(data.foo + "
" + data.bar + "
" + data.baz);
This lets you deal with your data piecewise, rather than in one lump, so it's easier to manipulate and parse.