简体   繁体   中英

Reload jQuery via button

I would like to reload the script if it suddenly doesn't work; no result come out.

I create a button <div id="totalnow">Reload</div> .

When i click Reload nothing happen, is there any option?

function totalnow() {
    var url="./ajax/totalvote.php";
    jQuery("#totalnow").load(url);
}
$(document).ready(function() {
    totalnow();
    setInterval("totalnow()", 7000);
});

You have never told jquery to respond to the click based on that code

$(function() {
  $('#totalnow').click(function() {
    totalnow();
  });
});

or

$(function() {
  $('#totalnow').click(totalnow);
});

depending if totalnow() is the only thing you want to do on that click

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