How do I POST variables using jQuery / Javascript to another

How do I use POST using jQuery/Javascript to send to another page and redirect to that page?Sending variables using GET…In Javascriptwindow.location = ‘receivepage.php?variable=’+testVariable;When it is receive by PHP…$var = $_GET[‘variable’];How do I do that ^ , using $_POST?I already tried…$.post(‘receivepage.php’, i: i , function() …

via PHP Website Development » Search Results » ajax:

How do I POST variables using jQuery / Javascript to another

How do I use POST using jQuery/Javascript to send to another page and redirect to that page?
Sending variables using GET…
In Javascript
window.location = ‘receivepage.php?variable=’+testVariable;When it is receive by PHP…
$var = $_GET[‘variable’];How do I do that ^ , using $_POST?
I already tried…
$.post(
‘receivepage.php’,
i: i
, function()
window.location = ‘receivepage.php’;

);but it seems to lose the variable when it reaches PHP
…………………………………..

In your post example, $_POST[‘i’], would be your variable.
…………………………………..

Doing $.post is trying to post the information via ajax, and THEN redirecting to your page, so when you finally get there, the attribute “i” won’t be received.
You could do someothing like this:
HTML


JS
Does that solve your problem?
Edit
If your value comes from JS, you can add it like this:
JS
According to your example, “i” is defined on the window scope, making it global and accessible from this script.

For more info: How do I POST variables using jQuery / Javascript to another

PHP Website Development » Search Results » ajax

How do I POST variables using jQuery / Javascript to another

Share this post:

Related Posts

Leave a Comment