Ok so i am trying to retrieve data from an ajax request and possibly if possible set a php array ...I am not even sure if this is possible considering one is client side and one is server side...so here is my code
on the html page
<?php foreach ($products as $product): ?>
<li>
<h3><span><?php print $product["price"]; ?></span> (4) <?php print $product["name"]; ?> </h3>
<div class="container">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" width="42"><span class="qty"><?php print $product["quanitity"]; ?></span></td>
<td width="180">
........
and I want to loop through all the products in this array but to get the products I need to make an ajax call like this
$.ajax({
type: 'post',
url: "/shop_systems/index.php?route=module/cart/get_all_products",
dataType: 'json',
data: {current : null, previous : these_ids, quantity : 1, multiple : true},
success: function (data) {
I was thinking if there was an easy way to do this ....I was thinking that one solution would be to write the html in the success part of the ajax call but I would have lots of append statements...any cleaner way would be appreciated
<script>var products = <?php echo json_encode($products); ?>;</script>