I have a problem, I want to fetch data from mysql using ajax and show it in one dropdown (select tag).
My problem is how do I send data to jQuery?
AJAX ja_drop.php
$query = "SELECT list_id,link,title FROM tbl_list ORDER BY title ASC;";
$result = mysqli_query($dblink, $query);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
$results[] = $row;
}
}
print_r($results);
jQuery code
$.post("ja_drop.php")
.done(function(obj) {
$("#ts56").text(obj);
// i want a loop statments for show data detail but not work any loop here
});
When I print the recive object to my jQuery code, it shows the following result:
[0] => Array (
[list_id] => 25
[link] => http://213.217.33.27/z_tree/znv3/test1.htm
[title] => Ab Madani Damavand (WL-Tehran-Tehran Tower)(10.234.159.59)(1395925)
)
[1] => Array (
[list_id] => 35
[link] => http://213.217.33.27/z_tree/znv3/test1.htm
[title] => Ab Madani Damavand (WL-Tehran-Tehran Tower)(10.234.159.59)(1395925)
)
[2] => Array (
[list_id] => 36
[link] => http://213.217.33.27/z_tree/znv3/test1.htm
[title] => Ab Madani Damavand (WL-Tehran-Tehran Tower)(10.234.159.59)(1395925)
)
[3] => Array (
[list_id] => 37
[link] => http://213.217.33.27/z_tree/znv1/test1.htm
[title] => Ab Madani Damavand (WL-Tehran-Tehran Tower)(10.234.159.59)(1395925)
)
As you see my above array have 4 index but when i want print array lenght show me wrong number
$("#ts56").text(obj.length); // show 902