[英]I am able to get the url from javascript function. I need same url to be stored in my database using php code.
[英]I am getting the same value when I click on add to cart in my code. It's an ajax response in php
这是脚本。 当我单击添加到购物车时,它从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;
}
您的请求已缓存。 设置cache: false
因为默认情况下为true 。
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 (){}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.