这是脚本。当我点击添加到购物车时,它只从php文件中的下面代码中选择单个值。但当我检查我的回复时,它显示了两个值,在我的页面上,我从数据库中获取所有值,但是当我点击添加到购物车时,我每次都获得相同的值:
<script>
$(document).ready(function() {
alert("Page loaded");
jQuery.ajax({
url: "<?php echo $BASE_URL; ?>daily_menu_dishes.php",
dataType : "html",
data:'store_id='+$("#store_id").val()+'&store_name='+$("#store_name").val(),
type: "POST",
success:function(data){
//alert(data);
$("#dily-meal-product-container").html(data);
//$("#calender_day").html(data);
//$("#loaderIcon1").hide();
},
error:function (){}
});
});
</script>
这是在php:
while($row=mysql_fetch_assoc($result)){
$html=' <div class="col-xs-6 col-sm-6 col-md-4 first_col" style="width:23.333%">
<div class="thumbnail">
<img class="img-responsive" src="http://teq-staging.com/maswad-phase2/storeadmin/uploads/dish_images'.'/'.$row['image'].' " width="250px;min-height:0px ! important;">
<div class="caption">
<div class="user">
<a style="cursor:pointer"> <img class="img-responsive" src="http://app.msdev.in/uploads/cooks/70X70/default-70X70.jpg" alt="Beenu"></a>
</div>
<div class="body-content" style="width:175px;">
<h2> <a>'.$row["dish"].'</a></h2>
<div class="add-items" style="width:100px;float:right">
<span id="add-item-mini-5" class="add-to-cart active" onclick="addToCart();">ADD to Cart</span>
</div>
<div style="font-size:20px;width:100px;float:left;mrgin-top:-55px;">
<i class="fa fa-inr"></i> '.$row["sell_price"].'
<input type="hidden" name="sell_price" id="sell_price" value="'.$row["sell_price"].'">
<input type="hidden" name="dish_name" id="dish_name" value="'.$row["dish"].'">
<input type="hidden" name="dish_id" id="dish_id" value="'.$row["id"].'">
</div>
</div>
<div class="veg-symbol"><i class="veg-circle"></i></div>
<!-- <ul class="last-tab">
<li id="favourite-5" onclick="addToFavorite(5, this)">
<i class="fa fa-heart"></i>Add to Favourite</li>
<li onclick="productDetailModal(5)"><i class="open-eye"></i>Know More</li>
</ul> -->
</div>
</div>
</div>
</div>';
echo $html;
}
答案 0 :(得分:0)
您的请求已缓存。自it is true by default以来设置cache: false
。
jQuery.ajax({
url: "<?php echo $BASE_URL; ?>daily_menu_dishes.php",
cache: false,
dataType : "html",
data:'store_id='+$("#store_id").val() + '&store_name=' + $("#store_name").val(),
type: "POST",
success:function(data){
//alert(data);
$("#dily-meal-product-container").html(data);
//$("#calender_day").html(data);
//$("#loaderIcon1").hide();
},
error:function (){}
});