-1

I'm posting Javascript array cellValues using following code:

$.post('test.php', {cellvalues: celValues});

test.php:

<?php
$i=0;
$arr= array();
foreach($_POST['celValues'] as $val)
{
    $arr[i]=$val;
    echo $arr[i];
    $i++; 
}

The PHP code is not working. So how can I assign the JS array into a PHP array?

4 Answers 4

2
$_POST['celValues']

should be

$_POST['cellvalues'] 
1

Like this:

$arr = $_POST['cellvalues'];

And in the Javascript:

$.post('test.php', {cellvalues: celValues.serialize()});
1
$.post('test.php', {cellvalues: celValues.serialize()});

As a side-note, is the variable celValues meant to be cellValues?

1

try like this. 'cellvalues' instead of cellvalues

$.post('test.php', {'cellvalues': celValues.serialize()});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.