I am using AJAX
for data communication from server but in case of success i want to write the data into span(id=cartcount)
but it's not worked please help how i achieve this concept
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);
}
});
}
}
try:
$('#cartcount').html(obj);
or
$('#cartcount').text(obj);