-1
即时通讯我的脚本我想从ajax.php读取并显示它们,并在我的ajax.php我想从数据库中获取。我的问题是从数据库取不工作!从ajax数据库取回
echo
'<?php while ($row = mysqli_fetch_array($products)):?>
<div class="item-in-cart clearfix">
<div class="image">
<img src="images/<?php echo $row['id'] ?>" width="124" height="124" alt="cart item" />
</div>
<div class="desc">
<strong>
<a href="product.html">s</a>
</strong>
<span class="light-clr qty">
<a href="#" class="icon-remove-sign" title="Remove Item"></a>
</span>
</div>
<div class="price">
<strong></strong>
</div>
</div>';
<?php endwhile;?>
$(document).ready(function(){
$(".addCart").click(function(){
var id = $(this).val();
$.ajax({
type:'post',
url:'ajax.php',
data :{
id : 'id',
},
success : function (response) {
$('#cart').html(response);
}
});
});
});
定义“不起作用”。还有,你为什么在浏览器中回显PHP代码? –
@SamiKuhmonen,因为我想给我一个回应,我在ajax中显示它们到我的索引页面 – sinak
你的代码中有语法错误。 – roberto06