1

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);
});
3
  • 1
    Would'nt it be better to make sure it doesn't suddenly not work ? Commented Jul 13, 2013 at 22:07
  • It's not directly related, but it's better to pass the actual function to run into setInterval, rather than a string of js code to be evaluated. You can use setInterval(totalnow, 7000) to do this. Commented Jul 13, 2013 at 22:09
  • @jcsanyi now I could see a big difference over here. Thank you! Commented Jul 13, 2013 at 22:24

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.