Hi,

I'm sending an array encoded with Json in my PHP code server-side, but
when I try to fetch it in JQuery, I don't know what is the type of the
object I'm dealing with, and I can't get any information of it.

I tried to access it with object.length, object[index] and so on, but
I'm allways getting "undefined".

PHP Code:

//example array
$arr = array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5);
echo json_encode($arr);

JavaScriptCode:

                                $.ajax
                                ({
                                                        type: "POST",
                                                        url: "/script/",
                                                        dataType : "json",
                                                        data: 
"id="+$("#distritos").val(),
                                                        success: function(data)
                                                        {
                                                                
alert(data.lenght);
                                                        }
                                });


I would be very grateful if anyone could help me,
Cheers,
Ygor

Reply via email to