ajax等待太久了

时间:2016-11-29 12:37:29

标签: jquery ajax

我在localhost中没有问题,但是当我上传到服务器等待变得太慢时。

image of speed

这是我的Ajax代码:

$('button[value="submit"]').click(function() {
        var dataSelect = $( "#select-store" ).val();

        $.ajax({
            type: "POST",
            data: {part: 'available-food', value: dataSelect},
            url: 'http://localhost/xxx/xxx/sss.php',
            beforeSend: function() {
                $('#delivery').fadeOut(300, function() {
                    $('#store').removeClass('col-md-6').addClass('col-md-12');
                });
            },
            success: function(response) {
                $('#show-foods').html(response);
                $('.food-hover').css('opacity', '0');
                $('.food').hover(function() {
                    $(this).find('.food-hover').animate({'opacity': '1'}, 200);
                }, function(){
                    $(this).find('.food-hover').animate({'opacity': '0'}, 100);
                });

                addToCart();
            }
        });
});

并添加到购物车:

function addToCart() {
        $('#add-to-cart').click(function(){
            var value = $(this).val();

            $('.shop').animate({left: 0}, 300, 'swing');
            $('.body-overlay').css('display', 'block');
            open = true;

            $.ajax({
                type: "POST",
                data: {part: 'add-to-cart', food_id: value, quantity: 1},
                url: 'http://localhost/xxx/xxx/zzz.php',
                beforeSend: function() {},
                complete: function() {},
                success: function(response) {
                    $('.shop #cart-list-items').html(response);
                    updateTotalCart();
                    updateTotalPrice();
                }
            });
        });
}

和updateTotalCart:

    function updateTotalCart () {
    $.ajax({
            type: "POST",
            data: {part: 'update-total-cart'},
            url: 'http://localhost/xxx/xxx/www.php',
            beforeSend: function() {},
            complete: function() {},
            success: function(response){
                $('.open-basket span').html(response);
            }
    });
}

和updateTotalPrice:

function updateTotalPrice () {
    $.ajax({
            type: "POST",
            data: {part: 'update-total-price'},
            url: 'http://localhost/xxx/xxx/aaa.php',
            beforeSend: function() {},
            complete: function() {},
            success: function(response){
                $('.basket footer #total-price').html(response);
            }
    });
}

我必须做什么?

我有太多的阿贾克斯。

0 个答案:

没有答案