On 3 Mar, 13:32, "T.J. Crowder" <[EMAIL PROTECTED]> wrote:
> Hi Geoff,

> > re var params = ({ count: counter });
> > I have just realised that the above is equivalent to
> > var params = 'count=' + counter;
> > Correct?
>
> No, they're different. This defines an object with a count property:
>
>     var params = { count: counter };
>
> This defines a url-encoded string (provided 'counter' is numeric or
> something):
>
>     var params = 'count=' + counter;
>
> The 'parameters' input to Ajax.Updater allows you to supply either. If
> you supply a Hash-like object, Ajax.Updater just converts it to a url-
> encoded string for you.

OK thanks for the info.

Cheers

Geoff

> --
> T.J. Crowder
> tj / crowder software / com
>
> On Mar 3, 10:57 am, geoffcox <[EMAIL PROTECTED]> wrote:
>
> > re var params = ({ count: counter });
>
> > I have just realised that the above is equivalent to
>
> > var params = 'count=' + counter;
>
> > Correct?
>
> > Cheers
>
> > Geoff
>
> > On 3 Mar, 10:31, "T.J. Crowder" <[EMAIL PROTECTED]> wrote:
>
> > > Geoff,
>
> > > The parameters you send with a request are name/value pairs. The
> > > 'parameters' option to Ajax.request can accept either a url-encoded
> > > string, or any Hash-compatible object from which it can get the names
> > > and values to send (seehttp://www.prototypejs.org/api/ajax/options).
> > > From the code you posted, unless 'counter' is a url-encoded string of
> > > some kind, you're not giving any name to your counter value.
>
> > > Perhaps this:
>
> > > function send(){
> > >     var params = $H({ count: counter });
> > >     new Ajax.Updater(
> > >         'updateDiv',
> > >         'send.php',
> > >         {
> > >             asynchronous:true,
> > >             method:'get',
> > >             parameters: params
> > >         }
> > >     );
>
> > > }
>
> > > With this PHP:
>
> > > <?php
> > > echo "Hello <p>";
> > > $cue = $_GET['count'];
> > > echo $cue;
> > > ?>
>
> > > In the send() method, I'm creating an object with one property (count)
> > > set to the value of the counter variable, and then wrapping that in a
> > > hash via $H (I'm not sure you really need to do that; you might try it
> > > without the $H call and see if it works).  (I could have done all that
> > > within the call to Ajax.Updater, but I thought it would be clearer
> > > doing it separately.)  Then in the PHP, I'm retrieving the 'count'
> > > parameter.
>
> > > Hope this helps,
> > > --
> > > T.J. Crowder
> > > tj / crowder software / com
>
> > > On Mar 3, 9:04 am, geoffcox <[EMAIL PROTECTED]> wrote:
>
> > > > No idea why my message appears twice!!?? Geoff
>
> > > > On 3 Mar, 09:02, geoffcox <[EMAIL PROTECTED]> wrote:
>
> > > > > Hello,
>
> > > > > I am trying to use Ajax.Updater to send a javascript variable value to
> > > > > MySQL.
>
> > > > > To simplify matters I just want to see what is sent first so I have
>
> > > > > <script type="text/javascript">
> > > > > function send(){
> > > > > var params = counter;
> > > > > new Ajax.Updater('updateDiv', 'send.php',
> > > > > {asynchronous:true,method:'get', parameters:params});
>
> > > > > }
>
> > > > > counter being the javascript variable value.
>
> > > > > Question is - what should I have in the sever side php file?
>
> > > > > At the moment in send.php I have
>
> > > > > <?php
> > > > > echo "Hello <p>";
> > > > > $cue = $_GET['params'];
> > > > > echo $cue;
> > > > > ?>
>
> > > > > The Hello does appear on the page but the $cue does not.
>
> > > > > How should I do this?!
>
> > > > > Cheers
>
> > > > > Geoff
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" 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/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to