开发者

What is [object] in PHP?

开发者 https://www.devze.com 2023-03-26 13:22 出处:网络
I\'m using AJAX to get data from server. The following is the php file. myphp.php $Product_name = $_POST[\'path\'];

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 respon开发者_C百科se 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?


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

Try this command

print_r($Product_name);

to see all objected variables


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消