0

I have a form, which I parse and attach it's information to an object called "data" which is passed into the ajax:

$.ajax({
        url: url,
        data:  data,
        type: "POST",
        inline: true,
        success: function (redirect) {
            console.log("success");

            // go to the redirect page -- ??
        }
    });

This works successfully, but I would like the page to refresh. Right not, it just returns the html, but does not refresh.

Using the form to submit is not an option, I'd need to create a separate form to submit from, but I do not know how to attach data to this form.

Any help is appreciated.


edit:

I will need to create a separate form as the one I am parsing for data does not always exist. this data then gets put into localstorage and is loaded at a later time. I'd like to be able to use saved data and build a submit form with it

abc
  • 11
  • 2
  • If you refresh you'll lose the returned HTML in success callback... using `location.reload();`. – Zakaria Acharki Sep 25 '18 at 16:31
  • yes. which is why I want to do a refresh from html. Using a separate form to submit and refresh the page would work as well – abc Sep 25 '18 at 16:31
  • Then you've to submit the form normally without ajax – Zakaria Acharki Sep 25 '18 at 16:32
  • I just don't know how to attach data to this new form. I have multiple fields that need to be attached (key: value) pairs. How do I create the html for the form? – abc Sep 25 '18 at 16:33
  • Why _Using the form to submit is not an option,_? you could use `form.submit()` – Zakaria Acharki Sep 25 '18 at 16:34
  • I will need to create a separate form as the one I am parsing for data does not always exist. this data then gets put into localstorage and is loaded at a later time. I'd like to be able to use saved data and build a submit form with it – abc Sep 25 '18 at 16:36

1 Answers1

0

use this in success method

location.reload();
Shailendra Gupta
  • 1,054
  • 6
  • 15