arraytest.html
<script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
<input type="button" id="btn" value="go to php" onclick="show()">
<br><br>
<script type="text/javascript">
var a = new Array(6,5);
function show(){
$.ajax({
type: "POST",
url: "arra.php",
data: {test : JSON.stringify(a)},
success: function(data) {
alert("success" +data);
}
});
}
</script>
arra.php
<?php
$arr = json_decode($_POST['test'], true);
$v = $arr[0] + arr[1] ;
echo $v ;
?>
i couldn't add the array values in php file. anybody could help me with this ? am getting the error as: Parse error: syntax error,unexpected '[' in c:\wamp\www\arra.php on line 3