Deb*_*mal 3 ajax jquery codeigniter
$('.cn').click(function() {
var pic_id = $(this).attr('href');
console.log(pic_id);
//alert(pic_id);
$.ajax({
type: "POST",
url: "<?php echo base_url();?>anda/coins",
async: false,
data: "pic_id="+pic_id,
dataType: 'json',
success: function(data){
//alert(data);
$('.cn_point').html(data.id);
}
});
});
Run Code Online (Sandbox Code Playgroud)
我得到了回调值并显示,但页面获取刷新值和span hide值.有没有人可以帮助我?我无法找到我的错误.
尝试使用preventDefault:
$('.cn').click(function (e) {
e.preventDefault();
var pic_id = $(this).attr('href');
console.log(pic_id);
//alert(pic_id);
$.ajax({
type : "POST",
url : "<?php echo base_url();?>anda/coins",
async : false,
data : "pic_id=" + pic_id,
dataType : 'json',
success : function (data) {
//alert(data);
$('.cn_point').html(data.id);
}
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3810 次 |
| 最近记录: |