In your ajax success callback do this: success: function(response){ setTimeout(function(){ location.reload() }, 5000); } As you want to reload the page after 5 seconds, then you need to have a timeout as suggested in the answer. You can also refresh the page at the given time interval using JavaScript. We can use the same code to repeatedly refresh the '#event' content using setInterval method. To control the loading order of scripts, you can actually use the dependencies parameter of wp_enqueue_scripts(). reload (); }); Solution 2 You use the ajaxStop to execute code when the ajax are completed: How can I upload files asynchronously with jQuery? What does "use strict" do in JavaScript, and what is the reasoning behind it? How Intuit democratizes AI development across teams through reusability. vegan) just to try it, does this inconvenience the caterers and staff? What am I doing wrong here in the PlotLegends specification? Why does Mister Mxyzptlk need to have a weakness in the comics? The setInterval() method takes two parameters the first one is a method name, that has the code to refresh or reload the page. You need to make sure that your unbind() function is called after the event binding has occurred. Also make sure that your script executes, Prevent page reload after ajax form submission, How Intuit democratizes AI development across teams through reusability. The click event gets lost because the refreshed element is "new" to the DOM on the page. The HTML page has a meta tag to refresh the page, You can set the time in the second and target page that will reload at the given interval. jQuery.ajax() | jQuery API Documentation Not the answer you're looking for? jQuery AJAX load() Method - W3Schools Have you tried setting the click event with the "on" method ? Do new devs get fired if they can't solve a certain bug? ~ Answered on 2014-12-26 07:48:57 Most Viewed Questions: You can use the reload function in your if condition for success and the page will reload after the condition is successful. I am using history.go() method to reload the currently active page bypassing '0' param. By clicking Accept all cookies, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy. Set a session in your php code with a variable. How is data-Ajax-update used in jQuery? The issue was with alert() box. Sorry man, this is my first time on this web site didn't notice the checkmark :S, Reload in existing page isn't functioning. Syntax: $ ( selector ).load ( URL,data,callback ); The required URL parameter specifies the URL you wish to load. Are there tables of wastage rates for different fruit and veg? I have PHP file which goes through the array deleting item by item from the database. How to set timeout for ajax by using jQuery? - GeeksforGeeks Best ways to fix 504 gateway time out in nodejs Applications, Fix for Error No configuration provided for scss, Multiple ways to List containers in a Docker with examples, What is the difference between Promise race and any methods with examples, What is the difference between Promise all and allSettled methods with examples. refresh an entire web page or just the content inside an element, How to refresh the contents of a DIV element automatically every few seconds using jQuery. If a question is poorly phrased then either ask for clarification, ignore it, or. 178K views 7 years ago Jquery Advance Tutorial How to do Auto Load and Refresh Div every Seconds with jQuery and Ajax. The second way to refresh is to use partial loading and it loads only those areas that have been changed. I will explain three ways of JavaScript to reload the page. Check the session is set and output the necessary message. Cache refresh: reloading a current page to get the data from a cache, hard refresh: reload page retrieves the data from a server. To learn more, see our tips on writing great answers. reload logic is placed inside a success callback that reloads the entire page. One reason is that the other script that binds the event might be loading in the footer, too. Sometimes, We need to reload the web page or refresh the page manually or automatically. If I open the page ([domain]/login) and hit the Submit Button the first two XHR occur of which the first one is correct. Asking for help, clarification, or responding to other answers. contentType:'application/json;charset=utf-8', ,