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
tonelm54Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tonelm54Author Commented:
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?"
0
GaryCommented:
Does not target="_blank" in the FORM tag not work?
0
tonelm54Author Commented:
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
0
GaryCommented:
This is one possible easy way

$.ajax({
        type: "POST", 
        url: "posttopage.php",
        data: "myvar=" + mydata,
        success: function(response){
            var new_window = window.open();
            new_window.document.write(response);
        }
})

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.