I am using jQuery and PHP. I have a JavaScript array, when I pass it to the server and try to retrieve the array, I can only get the last element. Why is that and how can I get my array values properly?
JavaScript:
var arr = [] ;
arr.push("kanishka");
arr.push("bandara");
jQuery.ajax({
type: "post",
url: baseurl+"profile/mprofile/action/ratings/add_ratings",
data:{ "arr":arr},
success: function(data, status) {
jQuery('#header-error').html(data);
}
});
PHP:
$arr = $this->ci->input->post('arr');
pre($arr);
die;
Result shown in FireBug:
<pre>bandara</pre>