Inserting each .post data into a <td> using .each
I was wondering if this is possible to be done with jquery. Please see following code.
HTML
<table id="order">
<tr>
<td class="order_items"></td>
<td class="order_items"></td>
<td class="order_items"></td>
<td class="order_items"></td>
<td class="order_items"></td>
<td class="order_items"></td>
</tr>
<tr>
<td class="order_items"></td>
<td class="order_items"></td>
<td class="order_items"></td>
<td class="order_items"></td>
<td class="order_items"></td>
<td class="order_items"></td>
</tr>
<tr>
<td class="order_items"></td>
<td class="order_items"></td>
<td class="order_items"></td>
<td class="order_items"></td>
<td class="order_items"></td>
<td class="order_items"></td>
</tr>
</table>
javascript
$(document).ready(function(){
$("td.load_ads").each(function(){
$(this).html("Place a New Ad Free!");
});
var count=$("td.load_ads").length; //18
$.post('/fetch_orders.php',{count:count},function(data){
var data_arr=data.split('/end');
for(index=0;index < data_arr.length;index++){ //for each of the array values got back from fetch orders.php
.
..
... Stuck here. How to make each data_arr(ie: each data_arr[index]) go into each td?
.POST script
$count =$_POST['count'];
$query="SELECT * FROM orders1_manager_orders ORDER BY RAND() LIMIT $count";
$db->setQuery($query);
$ads=$db->loadRowList();
foreach($ads as $ads_to_display){
echo $orders_to_display[9].'/';
echo $orders_to_display[10].'/end';
}
As explained in the title, i need each order to go into each empty td slot in the above html table. But if i were to put a .each function after my .post All of my tds will turn into the first data gotten from the script, meaning data_arr[1].
Total Views: 165 Today Views: 0













