Returning a PHP array as json

Im not sure if this belongs to a jquery or PHP forum depending on which area Im screwing up!

I have an AJAX call in jquery that submits the POST data from a from using jquery’s form.seralize() method to a php file.

I am returning the values from the php file like this:

$str = json_encode($_POST);
echo $str;

I am looping through the data returned from the PHP file in my jquery like this:

$.post(‘php_file.php’, $this.serialize(), function(data){
$.each(data, function(key, value){

But instead of looping through each key:value pair, it loops through each letter arggghhhh what I’m I doing wrong?

I think Ive got the data as a string and not an object? Very confused :frowning:

  1. Documentation is found at

  2. Read the comments to find others with the same problem

  3. Reason for failure is a known issue with 1.4.2

  4. Solution is to use jQuery.ajax() syntax instead

  5. Code for jQuery.ajax() syntax is found near the top of the [url=“”] page

Thanks a lot! Appreciate that…