开发者

Reload script into div with ajax at the end of server side script

开发者 https://www.devze.com 2023-03-19 11:22 出处:网络
I have a shopping cart where minicart.php at the top of each page adds products sent to it with ajax load (POST) and update cart-sessions开发者_Go百科.

I have a shopping cart where minicart.php at the top of each page adds products sent to it with ajax load (POST) and update cart-sessions开发者_Go百科.

On one page another script further down the code, cart_list.php filters the cart amount for valid/invalid promotions. If it finds an invalid promotion it will delete it from the cart-session.

I reload minicart.php when cart_list.php is loaded but it doesent get the change. I also tried adding a timeout if it were a raceproblem.

("#cart").load("/cart_list.php", {amountchange:amount,key:key}, function() {
        setTimeout(function() {
            $("#minicart").load("/minicart.php", {calledsolo:"true"});
            floatingBox();
        }, 500);
    });

If I put cart_list.php above mini_cart.php in the code it works but I prefer not to do that it possible, also I would like to understand why since mini_cart.php should reload indepentently anyway.

How can I solve this?


$("#minicart").load("/minicart.php", {calledsolo:"true"});

this call does not wait until it completes. so floatingBox(); got called before the above ajax-call completes. try following:

("#cart").load("/cart_list.php", {amountchange:amount,key:key}, function() {
            $("#minicart").load("/minicart.php", {calledsolo:"true"}, function(){
                floatingBox();
            });
    });
0

精彩评论

暂无评论...
验证码 换一张
取 消