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

6
  • If you refresh you'll lose the returned HTML in success callback... using location.reload();. Commented Sep 25, 2018 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 Commented Sep 25, 2018 at 16:31
  • Then you've to submit the form normally without ajax Commented Sep 25, 2018 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? Commented Sep 25, 2018 at 16:33
  • Why Using the form to submit is not an option,? you could use form.submit() Commented Sep 25, 2018 at 16:34

1 Answer 1

0

use this in success method

location.reload();
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.