0

I have a function with ajax in it :

    function get_cart_count(){
      $.ajax({
        url: "/cart/count",
        method: "get",
        async: false,
        success: function (count) {
            if (count > 0) {
                // console.log('count is :' + count);
                return count;
            }
        },
      });
    }

as you see the async is false.

the count is log is 1, but when I console.log(get_cart_count()) , it give me undefined ! why this happening ?

thanks

aref razavi
  • 413
  • 2
  • 12

0 Answers0