On Oct 28, 2012, at 4:15 AM, donnek wrote:
> I'm new to Prototype, and I'm trying to use AJAX to update divs inthe
> background, pulling data from a database. I've got Ajax.Updater to work with
> the output of a form, but I'm having difficulty with adpting it for use with
> a link. Basically, I have a list of words produced by the db, each of them a
> clickable link, and when I click on the word I want the context of the word
> (likewise drawn from the db) to come up in a div below the list.
>
> What I have at the minute:
>
> calling page:
> <div><a href="javascript:void(0);" class='textword' id='myword1'
> onclick="get_word()">myword1</a></div>
> <div><a href="javascript:void(0);" class='textword' id='myword2'
> onclick="get_word()">myword2</a>
> <div id="output">[Results appear here.]</div>
> <script>
> function get_word()
> {
> new Ajax.Updater
> (
> 'output',
> 'mylist.php',
> {
> method: 'get',
> parameters: { word: $(this).attr("id") }
I'm pretty sure your problem is right here. There's no attr() method in
Prototype. Try readAttribute() instead, and you appear to have everything right
besides.
Walter
> }
> );
> }
> </script>
>
> mylist.php:
> [db connection stuff]
> $word=trim($_GET['word']);
> $sql=query("select * from mytable where word~'$word';");
> while ($row=pg_fetch_object($sql))
> {
> echo $context."<br />";
> }
>
> Run by itself, mylist.php gives the results I want, so I think I haven't got
> the right invocation for the link, but after several hours searching and
> experimenting, I have to ask!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Prototype & script.aculo.us" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/prototype-scriptaculous/-/z616OxDuu6oJ.
> 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.
--
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.