spstieng wrote: > Ah, got it. > > The Post is correct and the Respons is correct... I think. It's in > JSON, but not sure if it's correct. > > According to http://docs.jquery.com/Ajax/jQuery.post, last example, > they have the following line in the php file: > <?php echo json_encode(array("name"=>"John","time"=>"2pm")); ?> > This is why they can output the info by alert(data.name). > > But if I try this: > while ($row = mysql_fetch_array($result)) > { > $data[] = array( > "id"=>($row['id']) , > "name"=>($row['name'])); > } > $storeData = json_encode($data); > > I still get 'undefined' output :( >
It seems that you will get multi row array with that php code. Try to fetch one row only, then store it with: $data['id'] = $row['id']; $data['name'] = $row['name']; $storeData = json_encode($data); You get undefined, because you try to alert an array. -- Donny Kurnia http://hantulab.blogspot.com http://www.plurk.com/user/donnykurnia