Or if you mean passing the contents of the php variable $var to 'test2.php'
then you can do so like this
--> in your JS
Event.observe(document,'dom:loaded', function() {
new Ajax.Updater('debug','test2.php', {
parameters : {var: '<?php echo($var); ?>',anotherParam:
'blah',yetAnotherParam: 'Boing'}, onComplete: function(transport)
{
var data=transport.responseText;alert(data); }
});
});
HTH
Alex
----- Original Message -----
From: "Alex Mcauley" <[email protected]>
To: <[email protected]>
Sent: Tuesday, March 03, 2009 1:06 PM
Subject: [Proto-Scripty] Re: Ajax.Request and php global variable
>
> global how .. that doesnt really explain much
>
>
> If you mean globaly accessible to javascript then you need to do something
> like
>
> <?php
> $bar='bar';
> echo("<script>foo=$bar</script>");
>
> ?>
> ....
>
> <script>alert(foo);</script>
>
> ...
>
> otherwise please be more specific
>
> Thanks
> Alex
>
>
> ----- Original Message -----
> From: "marioosh" <[email protected]>
> To: "Prototype & script.aculo.us"
> <[email protected]>
> Sent: Tuesday, March 03, 2009 12:38 PM
> Subject: [Proto-Scripty] Ajax.Request and php global variable
>
>
>>
>> I have a code as below:
>>
>> test1.php:
>> ----------
>> <html>
>> <head>
>> <meta http-equiv="Content-Type" content="text/html;
>> charset=UTF-8">
>> <script type="text/javascript" src="resources/scriptaculous-
>> js-1.8.2/lib/prototype.js" ></script>
>> <script type="text/javascript" src="test1.js" ></script>
>> </head>
>> <body>
>> <?php
>> // want to be global, but how???
>> $var = 'test';
>> ?>
>>
>> <div id="debug"></div>
>> </body>
>> </html>
>>
>>
>> test1.js:
>> ----------
>> Event.observe(document,'dom:loaded', function() {
>> new Ajax.Updater('debug','test2.php', {
>> onComplete: function() {
>> }
>> });
>> });
>>
>>
>> test2.php:
>> ----------
>> <?php
>> echo "var = ".$var;
>> ?>
>>
>> (http://pastie.org/405875 for better view)
>>
>> How to make $var to work as global within Ajax.Request ?? Is this
>> possible ?
>> Thanks in advance for help.
>>
>> >
>>
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---