我正在使用 AJAX
与服务器进行数据通信,但如果成功,我想将数据写入 span(id=cartcount)
但它不起作用,请帮忙我如何实现这个概念
function addToCart(pid, name) {
if (confirm("Are you sure to add "+name + " to cart?")) {
$.ajax({
type: 'POST',
url: 'addcart',
data: {
pid: pid
},
success: function(obj) {
$('#cartcount').val(obj);
}
});
}
}
最佳答案
尝试:
$('#cartcount').html(obj);
或
$('#cartcount').text(obj);
关于java - 当我使用 jQuery EasyUI 时,如何在跨度中写入数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28583907/