Is there a way I can pass a PHP variable from a PHP page to a JQuery page and back to a PHP page?
+2
A:
Maybe I'm wrong but I believe you may be confusing things.
- Server Generates page using PHP.
- Generated page is composed of HTML, JAVASCRIPT whatever...
- Client receives page
- Received page is interpreted (JavaScript code is run)
In the end what you are asking for is possible but, by the way you put the question, I though that the above should be clarified.
How to do it?
Say you want to pass id=123 from server to client and then back.
- generate page with a tag, say
<span id="js-val">123</span> - have client read the contents of
id="js-val - client can then resend the 123 using
POSTorGETthat really depends on what you want.
Hope it helps to clear things up.
Frankie
2010-08-06 03:28:35
You could generate the JavaScript/jQuery using PHP.It'd be a little slower, but you could directly pass strings to the code.
Alexander
2010-08-06 03:42:31
@TheLifelessOne you can have Apache interpret .js files as php and use it only where you need having the whole file written as javascript and only small portions as php like `<?=date()?>` for example. But that goes beyond the scope of the question.
Frankie
2010-08-06 04:07:23