Ajax browser refresh in background

筅森魡賤 提交于 2019-12-11 20:49:50

问题


i am trying to produce a browser refresh in the background after a click.

My issue is i am allread using ajax to process other element on the page but i need these to be updated.

// approved - allready approved section

$('.allready_approved').click(function(event) {
        event.preventDefault();                 
    $('#main_bloc_approved').slideUp();

    // i need to perform a browser refresh here but without reloading the page here???

     $('#main_bloc_allready_approved').fadeIn();                    
     return false;


     return false;
});

$('.approved').click(function(event) {
            event.preventDefault();             
    $('#main_bloc_allready_approved').slideUp();

     // i need to perform a browser refresh here but without reloading the page here???

     $('#main_bloc_approved').fadeIn();
     return false;
});

回答1:


I think you should use, unless I have misunderstood you :)

$(document).ready(function (){
   $('body').load(window.location.href,'body');
});

also convert your .click (...) into .live('click',...)

also you have return false; twice which is only needed once really.

Not that I wanna be technical about this but,

(number of clicks + number of unnecessary bytes) * number of users = better think of another way e.g. .setTimeout() to update every minute to save some bandwidth or you will go bankrupt before you care to think :) but thats my opinion and not a fact :)



来源:https://stackoverflow.com/questions/5296815/ajax-browser-refresh-in-background

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!