I am getting satisfactory output like this :
From this php foreach loop(on view and gettinf details from model and controller) and I am getting data from mysql database tables according to the condition as:
<tfoot>
<?php foreach ($orders as $k => $v) {
$order_item = $this->vendor_model->getOrdersItemData($v['o_id']); ?>
<tr>
<td><?php echo $v['o_id']?></td>
<td><?php echo $v['t_id']?></td>
<td><?php echo $v['grand_total']?></td>
<td><?php echo $v['order_status']?></td>
<!--Datavariable for orders-->
<td>
<table>
<thead>
<tr>
<td>Product Name</td>
<td>Quantity</td>
<td>Price</td>
</tr>
</thead>
<tbody>
<?php foreach ($order_item as $k => $p) {
$product_item = $this->vendor_model->getProductData($p['product_id']); ?>
<tr>
<td><?php echo $product_item['product_name']?></td>
<td><?php echo $p['quantity']?></td>
<td><?php echo $product_item['product_price']?></td>
<!--data variable for order items-->
</tr>
<?php }?>
</tbody>
</table>
</td>
</tr>
<?php }?>
</tfoot>
</table>
I am trying to do this in ajax like this:
$.each(data, function(k, v) {
var product_item = < ? = json_encode($this - > vendor_model - > getOrdersItemData("19", JSON_HEX_TAG)) ? > ;<!--Is there any way to get this "19 from data by loop"-->
html += '<tr>' +
'<td>' + v.o_id + '</td>' +
'<td>' + v.u_id + '</td>' +
'<td>' + v.grand_total + '</td>' +
'<td>' + v.order_status + '</td>' +
//'<td>'+k + ": " + v.t_id+'</td>'+
//'<td>'+'<pre>'+JSON.stringify(data)+'</td>'+
'<td>' + '<pre>' + product_item.oi_id + '</td>' +
'<td>' +
$.each(product_item, function(k, v) {
html += '<table>' +
'<tr>' +
'<td>' + k + ": " + v.oi_id + '</td>' +
'<td>' + '<pre>' + JSON.stringify(product_item) + '</td>' +
'</tr>' +
'</table>';
}) +
'</td>' +
'<td>' +
'<a href="javascript:;" class="btn btn-success item-view" data="' + this.o_id + '">View</a>' +
'<a href="javascript:;" class="btn btn-info item-edit" data="' + this.o_id + '">Edit</a>' +
'<a href="javascript:;" class="btn btn-danger item-delete" data="' + this.o_id + '">Delete</a>' +
'</td>' +
'</tr>';
});
I am just starting Ajax, is there any way to do this in ajax and I know there are lots of mistakes going on as well in my ajax.
I want to do that php forloop output from ajax.