fawad
fawad

Reputation: 1353

What is [object] in PHP?

I'm using AJAX to get data from server. The following is the php file.

       myphp.php

    $Product_name = $_POST['path'];
        $message['message'] .= '<tr><td>' . ($Product_name) . '</td></tr>';
$message['message'] .= '</table>';
    echo json_encode($message);
        ......

When i get response on html page I'm getting '[object]'.

$.ajax({
                   type: "POST",
                   url: "uploader.php",
                   async: false,
                   data: {submit_question:'1', 
                       path: $("[name='path']").val()},


                   success: function(response, status){
                            var ajax_message = jQuery.parseJSON(response);

                            $('#status').html(ajax_message.message);



                   }

                 });

Can anybody tell me what does this mean?

Upvotes: 1

Views: 85

Answers (2)

MacMac
MacMac

Reputation: 35321

Try using

alert(ajax_message.message.toSource());

Placed after the parseJSON to see the full response, you can use the $.each function to walk over the object revealing your values inside the object.

Upvotes: 1

genesis
genesis

Reputation: 50976

it means that you probably fetched this from database as an object.

Try this command

print_r($Product_name);

to see all objected variables

Upvotes: 1

Related Questions