Avatar of tonelm54
tonelm54 asked on

Create form and submit

Ive been look at ways of transferring data between pages, currently I use GET such as:-
window.location = "newPage.php?myVariable=myValue";

Open in new window

What I would like to do is use POST instead, however on reading up there is no way of posting data to another page and showing the result. I know I can submit a form to a page, and look at the data, but if I want to transfer my data to a new page (as a normal form redirects you to another page).

What I was thinking of doing is creating an element of a form, and submitting the form into a new page.

So, looking into this I thought I could use .submit() on a forms ID, however this doesn't redirect the form.

I know I could submit a form, and then put the returned string (html code) into a div on the current page, but would prefer to redraw the entire page.

Has anyone had any experience or idea how I can create a POST request, submit it to a page and then view the page completely?

Thank you

Avatar of undefined
Last Comment

8/22/2022 - Mon

A simpler view of my question is "How do I use jQuery to redirect a user to a new page (either same or new window) with POST data?"

Does not target="_blank" in the FORM tag not work?

GaryC123 -> Yes it would, however I dont really want to actually code a form inside the HTML, Id prefer to do it all in a jQuery function, but have no idea how to create a form inside a function and the submit it to a new page
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question