I have an AJAX call returning an array to a PHP-HTML page.
Here are some blocks of codes:
Javascript:
"Note: get_data.php returns an HTML string, and I want to store it in an array."
var param_array = new Array();
$.post('get_data.php', { id: id }, function(data))
{
param_array.push(data);
$('#hidden_input').val(param_array);
}
HTML:
<form action='my_function' method='post'>
<input type='hidden' id='hidden_input' name='array_from_ajax'>
<input type='submit' name='btn_submit'>
</form>
PHP - CodeIgniter:
my_function()
{
$param_array = $this->input->post('array_from_ajax');
print_r($param_array); // Will this work? will $param_array contain the value?
}
Questions:
- Is it possible to return an array value and insert it into the HTML page?
- Is a JavaScript array the same as a PHP array?
- In the end, will my
$param_array
in PHP contain the value passed from the AJAX call?