使用$ .Post将JSON-ed数组传递给PHP

I have this code:

$("#sendData").click(function(e) {

// converts to JSON the array and returns a string.
var updateValues = JSON.stringify(dataArray); 

$.post("test.php", updateValues, function(data){
    document.write(alert)});
});

As you may see, is my intention to send a JSON array to test.php. Now in test.php i have something like:

<?php

    if(isset($_POST["updateValues"])) {
        echo $_POST["updateValues"];
    } else {
        echo "Error."
    }

?>

Now, i'm getting "Error". I believe it's because the array can not be passed just that way, even if it's JSON-ed. What's the correct way of passing arrays to PHP scripts?

Try...

$.post("test.php", {'updateValues': updateValues}, function(data){
        alert(data);
});

You had a few syntax issues - and each post variable should have a key in the object to access it in PHP like that.