I am writing the following code below, which basically takes the data from the current date to a PHP file to handle in jQuery. Until here everything well. But I'm not understand why I can not have a new value of the total variable after it picks the value coming PHP file.
day.each(function () {
        var $this = $(this);
        var the_index = $this.index();
        var the_date = $this.find('h3.date').html().substr(0,2);
        var the_day = $this.find('h3.day');
        /*THIS VARIABLE*/   
        var total = 0;
        $.get('trd/datetime.php', function (date) {
            if(that.hasClass('list-'+date.day)) {
                weekList.find('.item.list-'+date.day).addClass('active');
            }
            total = date.firstDate;
        }, 'json');
        console.log(total);
    });
I don't know if my english helps, but, please, tell me what wrong I'm doing!
Thanks.
 
    