|
|
|
|
Thread title: How can I pass a variable from Javascript to PHP? |
|
|
|
|
|
Thread tools
Search this thread
Display Modes
|
|
08-20-2008, 11:57 AM
|
#1
|
Status: Member
Join date: Aug 2008
Location:
Expertise:
Software:
Posts: 101
|
How can I pass a variable from Javascript to PHP?
Please explain me that how can i pass a variable from javascript to PHP?
|
|
08-20-2008, 12:03 PM
|
#2
|
Status: Paladin
Join date: Jul 2006
Location: Sheffield, UK
Expertise: design, front-end markup
Software: Photoshop
Posts: 2,353
|
The only way you can do it is by a page load. So basically, your javascript will need to locate the person to say, page.php?var1=result
Then in php, you can get the value of var1 using a simple, echo $_GET['var1'];
And also for future reference, try google.
|
|
08-21-2008, 06:28 AM
|
#3
|
Status: Member
Join date: Aug 2008
Location:
Expertise:
Software:
Posts: 101
|
Originally Posted by enigma
The only way you can do it is by a page load. So basically, your javascript will need to locate the person to say, page.php?var1=result
Then in php, you can get the value of var1 using a simple, echo $_GET['var1'];
And also for future reference, try google.
|
Any other way to pass variable. I mean to say through Coding.
|
|
08-21-2008, 08:32 AM
|
#4
|
Status: Paladin
Join date: Jul 2006
Location: Sheffield, UK
Expertise: design, front-end markup
Software: Photoshop
Posts: 2,353
|
|
|
08-21-2008, 04:09 PM
|
#5
|
Status: I'm new around here
Join date: Jul 2008
Location:
Expertise:
Software:
Posts: 13
|
Agree with enigma. I had to do this for a client once and from my hours of research online the method outlined by him is pretty much your only way.
|
|
08-21-2008, 11:17 PM
|
#6
|
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
Posts: 6,894
|
Originally Posted by shilpamg
Please explain me that how can i pass a variable from javascript to PHP?
|
With an AJAX call. There is no way to do it otherwise because javascript runs after PHP is compiled on the server. It basically works like this:
Client Request -> Server processes request (PHP or other server side languages run here) -> Server sends output to browser -> Browser reads output (HTML, JS, ect.) -> Finished product
Therefore you are not able to send something backwards on the line.
|
|
08-25-2008, 07:03 AM
|
#7
|
Status: Member
Join date: Aug 2008
Location:
Expertise:
Software:
Posts: 101
|
Originally Posted by ibumoden
Agree with enigma. I had to do this for a client once and from my hours of research online the method outlined by him is pretty much your only way.
|
Ohhhh!
Not satisfactory Answer.
|
|
08-25-2008, 11:10 AM
|
#8
|
Status: Paladin
Join date: Jul 2006
Location: Sheffield, UK
Expertise: design, front-end markup
Software: Photoshop
Posts: 2,353
|
Originally Posted by shilpamg
Ohhhh!
Not satisfactory Answer.
|
Read all the comments, villiage idiot explains it.
Understand this, "You can NOT do it the way you want to" !!
Use GOOGLE.COM to research!!!
It's not hard.
|
|
08-25-2008, 12:08 PM
|
#9
|
Status: Junior Member
Join date: Jul 2008
Location:
Expertise:
Software:
Posts: 52
|
Originally Posted by shilpamg
Ohhhh!
Not satisfactory Answer.
|
Thats really quite ungratefull, many people posted answers that are 100% correct to help, just because it doesnt suit you isnt their fault they provided you with information that you could have easily found by using google.com i think a simple thank you would have been better
|
|
08-25-2008, 12:14 PM
|
#10
|
Status: Superstar
Join date: Apr 2005
Location:
Expertise:
Software:
Posts: 4,449
|
Originally Posted by enigma
Read all the comments, villiage idiot explains it.
Understand this, "You can NOT do it the way you want to" !!
Use GOOGLE.COM to research!!!
It's not hard.
|
But you were wrong. Village Idiot explained the only way was through AJAX, not via a redirect. Perhaps you should brush up on your research, or stop shoving that suggestion down others throats.
Regards,
Jeff
|
|
|
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|