简体   繁体   中英

start auto refresh page with click on button

i have a update panel that contain gridview i wanna this page be auto update. i wrote fallowing snippet but my problem that when i locate this code in document.ready its work Properly but when i locate it in on click of button it dont work its my code;

   var temp;
    $(document).ready(function () {
            var refreshId = setTimeout(function () {
             if (temp == 1) {
                $('#menu').load('WebForm11.aspx');
                }
            }, 5000);
    });

    function Button2_onclick() {
        temp = 1;
    }

Try SetInterval insteadof SetTimeout

var temp;
    $(document).ready(function () {
            var refreshId = SetInterval(function () {
             if (temp == 1) {
                $('#menu').load('WebForm11.aspx');
                }
            }, 5000);
    });

    function Button2_onclick() {
        temp = 1;
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM