AJAX reload page with POST

ajax reload page without refresh
refresh page after ajax success mvc
refresh page ajax php
jquery reload page
how to refresh a part of page using ajax
how to refresh a page automatically in ajax
javascript reload page
refresh using ajax

Can anybody tell me how to refresh the current page with JavaScript, having a POST variable modified or added?

To be clear, I want to set some POST variables prior to reloading the page.

By using jquery ajax you can reload your page

    type: "POST",
    url: "packtypeAdd.php",
    data: infoPO,
    success: function() {   

jQuery Refresh/Reload Page if Ajax Success after time, In your ajax success callback do this: success: function(data){ if(data.success == true){ // if true (1) setTimeout(function(){// wait for 5 secs(2)  Each view contains a datatables.net datatable. When a row is selected within the table in partial view one, a jquery ajax post is made that causes partial view 2 to refresh with an updated datatable showing results based off of the row selection that was made in partial view 1.

If you want to refresh the entire page, it makes no sense to use AJAX. Use normal Javascript to post the form element in that page. Make sure the form submits to the same page, or that the form submits to a page which then redirects back to that page

Javascript to be used (always in myForm.php):

function submitform()

Suppose your form is on myForm.php: Method 1:

<form action="./myForm.php" method="post" id="myForm">

Method 2:


<form action="./myFormActor.php" method="post" id="myForm">


    //all code here, no output
    header("Location: ./myForm.php");

Refresh page after posting data to server via Ajax, I was trying to make the refresh occur after a successful POST but it doesn't happen. The POST occurs from a page with the ID of #update. You might not need AJAX to do this; AJAX is used if you need to get information from the database. If I’m misunderstanding and you do need to update just the div, the #main tag (line 4 of the last coding section in the article) references the Div with the ID of Main and loads the information from the PHP page into that specific div.

Reload the current document:

 <script type="text/javascript">
 function reloadPage()

Why is my ajax call refreshing the page?, After catching a submit and giving an event with it, you should prevent the default refresh of a browser: event.preventDefault();. Now your code will look as follow: $​  The setTimeout() method sets the time (in milliseconds) before the associated function will be executed. In the above code, the function is location.reload() — the page will reload in 1500 milliseconds (1.5 seconds). Buttons And setTimeout. You can combine the jQuery button click() function with setTimeout() and location.reload():

There's another way with post instead of ajax

var jqxhr = $.post( "example.php", function() {
  alert( "success" );
  .done(function() {
    alert( "second success" );
  .fail(function() {
    alert( "error" );
  .always(function() {
    alert( "finished" );

Reload or Refresh a Page after Ajax Success using jQuery, You can use the .reload() method inside an Ajax success callback function using jquery. I use Jquery to call Ajax. The server returns Json object with value "true or false" like this: return Json(new { success = false, JsonRequestBehavior.AllowGet }); Is there any way to refresh page

How to refresh page using jquery ajax? - JavaScript, ajax({ url: 'http://example.com/refresh.php', success: function(data) { if (data == "​refresh"){ window.location.reload(); // This is not jQuery but simple plain ol' JS } } });. If you want to refresh the entire page, it makes no sense to use AJAX. Use normal Javascript to post the form element in that page. Make sure the form submits to the same page, or that the form submits to a page which then redirects back to that page. Javascript to be used (always in myForm.php):

Submitting Forms Without Reloading The Page: AJAX , There are a lot of “without-page-refresh” solutions out there, but here's Usually, we would send a POST request to the server, handle it and  $.ajax({ data: sampleData, type: 'POST', url: AjaxObject.ss_ajax_url, success: function(msg) { window.location.reload(true); } }); As you can see, I perform a page reload with window.location.reload(true); in order to refresh a list of products on a page (since a product has just been deleted).

How to Refresh Page Using JavaScript & jQuery, The jQuery AJAX also use to refresh the page. Sometimes, We need to reload the web page or  Reload the table data from the Ajax data source. In an environment where the data shown in the table can be updated at the server-side, it is often useful to be able to reload the table, showing the latest data. This method provides exactly that ability, making an Ajax request to the already defined URL (use ajax.url () if you need to alter the

  • I edited your question for clarity, based on your comments under answers.
  • @StuperUser I know I can make it with GET variables by window.location.href, but I would like to achieve this by a post variable, and don't know how. I think with XMLHttpRequest is not a very good choice.
  • As @Pranav Hosangadi's said, if you're reloading the whole page, why are considering XHR rather than a normal HTTP Request? The whole point of XHR is that you don't have to reload the entire page.
  • This depends on jQuery, since the OP has only tagged this with JavaScript, make sure you refer to jQuery in your answer. It's also useful posting a link to the jQuery API docs if you refer to a jQuery function. You can also use post() instead of the longhand ajax() for this.
  • Yes, I already saw this possibility, but Im thinking if is possible to write something like XMLHttpRequest.setRequestHeader("name", "value");
  • If you want to add an additionnal content in you post, one way is to add a new hidden form element to the form before submitting it.
  • yes, but I need to set some post variables before. Is it possible?
  • Why u want through POST method
  • You can also this <script type="text/JavaScript"> <!-- function timedRefresh(timeoutPeriod) { setTimeout("location.reload(true);",timeoutPeriod); } // --> </script>
  • I'm just thinking about this. I know it can be very well achieved by setting the GET variables, but I just want to know if is possible to set POST variables.