I have to user a varible from javascript with PHP.
Can any one help me?
Use javascript varibles with PHP (This is an emergency)
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
It's been asked lots. Searching this forum (and Google) would have revealed that there are two ways to do it.
AJAX is the new preferred method.
Using window.location along with $_GET is the old-style way to do it.
some_php_script.php
AJAX is the new preferred method.
Using window.location along with $_GET is the old-style way to do it.
Code: Select all
var x = 42;
window.location='some_php_script.php?x='+x;Code: Select all
<?php echo $_GET['x']; ?>- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
It's probably too long a string for a URL, in which case you definitely need AJAX but anyway:aetoc wrote:sorry but I'm little confuse.
I want to save the window.source in a var from the page a and send it to page b.
can this help you.
Code: Select all
window.location = 'some_script.php?source=' + window.source;http://xajax.sourceforge.net/