Search code examples
javajavascriptajaxjquery-easyui

How I write data in span when i am using jQuery EasyUI


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);                         
                    }
                });
            }
        }

Solution

  • try:

       $('#cartcount').html(obj);
    

    or

    $('#cartcount').text(obj);