Hi, I am trying to make my way through prototype.js, especially the Ajax funtions. I have very little experience with javascript, know php really well though, so i am having trouble with it. I am making progress on all but the Ajax functions. Does anyone have an example using them? I am following this ajax tutorial and trying to convert it to use prototype.js http://www.sitepoint.com/article/remote-scripting-ajax code archive here http://www.sitepoint.com/examples/scripting/remotescriptexamples.zip He has two files receipt.php and example.xml . receipt.php determines if ''1234567'' is sent to it and returns the contents of example.xml. I am looking for a simple example like that. Thanks for your help, Chuck
chuck Clark wrote:> Hi, > I am trying to make my way through prototype.js, especially the Ajax > funtions. > I have very little experience with javascript, know php really well > though, so i am having trouble with it. I am making progress on all > but the Ajax functions. > Does anyone have an example using them? > > I am following this ajax tutorial and trying to convert it to use prototype.js > http://www.sitepoint.com/article/remote-scripting-ajax > code archive here > http://www.sitepoint.com/examples/scripting/remotescriptexamples.zip > > He has two files receipt.php and example.xml . receipt.php determines > if ''1234567'' is sent to it and returns the contents of example.xml. > > I am looking for a simple example like that. > > Thanks for your help, > ChuckHi Chuck, Have you seen the Curt Hibbs articles at onlamp.com? The first two take you through building a Rails app while the third looks into the Ajax capabilities of Rails. It might be a good place to start if you haven''t seen it. The third (ajax) article is here [1] and contains links to the two previous articles. Chris [1] http://www.onlamp.com/pub/a/onlamp/2005/06/09/rails_ajax.html
Thanks for the links Chris! I was more so looking for a pure prototype.js example, not with Rails though. Is there a more specific group to ask about prototype.js ? There is not much info out there about it, and the lack of documentation is making this difficult for me. Thanks, chuck On 7/25/05, Chris Roos <chris-zoUjy1rb4AnQXOPxS62xeg@public.gmane.org> wrote:> chuck Clark wrote: > > Hi, > > I am trying to make my way through prototype.js, especially the Ajax > > funtions. > > I have very little experience with javascript, know php really well > > though, so i am having trouble with it. I am making progress on all > > but the Ajax functions. > > Does anyone have an example using them? > > > > I am following this ajax tutorial and trying to convert it to use prototype.js > > http://www.sitepoint.com/article/remote-scripting-ajax > > code archive here > > http://www.sitepoint.com/examples/scripting/remotescriptexamples.zip > > > > He has two files receipt.php and example.xml . receipt.php determines > > if ''1234567'' is sent to it and returns the contents of example.xml. > > > > I am looking for a simple example like that. > > > > Thanks for your help, > > Chuck > > Hi Chuck, > > Have you seen the Curt Hibbs articles at onlamp.com? The first two take > you through building a Rails app while the third looks into the Ajax > capabilities of Rails. It might be a good place to start if you haven''t > seen it. The third (ajax) article is here [1] and contains links to the > two previous articles. > > Chris > > [1] http://www.onlamp.com/pub/a/onlamp/2005/06/09/rails_ajax.html > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
chuck Clark wrote:> Thanks for the links Chris! > I was more so looking for a pure prototype.js example, not with Rails though. > Is there a more specific group to ask about prototype.js ? There is > not much info > out there about it, and the lack of documentation is making this > difficult for me. > > Thanks, > chuck >I''m not sure there is a prototype.js group to be honest. I came across these prototype.js docs [1] on cpan a few days back. They may, or may not, be of some use to you. Have you got as far as updating a section of your page using ajax? If not, you might want to try this. <a href="#" onclick="new Ajax.Updater(''mydivhere'', ''myurlhere'', {asynchronous:true, evalScripts:true}); return false;">Testing Ajax</a> This will use ajax to call ''myurlhere'' and place the response in the dom element ''mydivhere''. If you want to use ajax to submit the contents of a form, use the following. <form action="myurlhere" method="post" onsubmit="new Ajax.Updater(''mydiv'', ''myurlhere'', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;"> <!-- form elements in here --> </form> Hope some of this helps, Chris [1] http://search.cpan.org/~sri/HTML-Prototype-1.30/lib/HTML/Prototype/Js.pm
I would recommend the following, instead. After all, requiring JS
isn''t very WaSP-friendly or accessibility-friendly.
<a href="myurlhere" onclick="new
Ajax.Updater(''mydivhere'',
''myurlhere'', {asynchronous:true, evalScripts:true}); return
false;">Testing Ajax</a>
On Jul 25, 2005, at 7:48 AM, Chris Roos wrote:
> <a href="#" onclick="new
Ajax.Updater(''mydivhere'', ''myurlhere'',
> {asynchronous:true, evalScripts:true}); return false;">Testing
> Ajax</a>
>
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails
Even better would be:
<a href="myurlhere" onclick="new
Ajax.Updater(''mydivhere'', this.href,
{asynchronous:true, evalScripts:true}); return false;">Testing
Ajax</a>
On 7/25/05, Toby Boudreaux <rails-lb8SQxIZKShBDgjK7y7TUQ@public.gmane.org>
wrote:>
> I would recommend the following, instead. After all, requiring JS
isn''t
> very WaSP-friendly or accessibility-friendly.
> <a href="myurlhere" onclick="new
Ajax.Updater(''mydivhere'', ''myurlhere'',
> {asynchronous:true, evalScripts:true}); return false;">Testing
Ajax</a>
>
> On Jul 25, 2005, at 7:48 AM, Chris Roos wrote:
>
> <a href="#" onclick="new
Ajax.Updater(''mydivhere'', ''myurlhere'',
> {asynchronous:true, evalScripts:true}); return false;">Testing
Ajax</a>
>
>
>
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
>
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails
True, except I made a mistake in my example.
I imagine you don''t want to send a user directly to the url used for
an AJAX call. I should have written:
<a href="myurlhere" onclick="new
Ajax.Updater(''mydivhere'',
''myAJAXurlhere'', {asynchronous:true, evalScripts:true});
return
false;">Testing Ajax</a>
For direct links, though, this.href is far better!
On Jul 25, 2005, at 9:33 AM, Steve Willer wrote:
> Even better would be:
>
> <a href="myurlhere" onclick="new
Ajax.Updater(''mydivhere'',
> this.href, {asynchronous:true, evalScripts:true}); return
> false;">Testing Ajax</a>
>
>
>
> On 7/25/05, Toby Boudreaux
<rails-lb8SQxIZKShBDgjK7y7TUQ@public.gmane.org > wrote:
> I would recommend the following, instead. After all, requiring JS
> isn''t very WaSP-friendly or accessibility-friendly.
>
> <a href="myurlhere" onclick="new
Ajax.Updater(''mydivhere'',
> ''myurlhere'', {asynchronous:true, evalScripts:true});
return
> false;">Testing Ajax</a>
>
> On Jul 25, 2005, at 7:48 AM, Chris Roos wrote:
>
>> <a href="#" onclick="new
Ajax.Updater(''mydivhere'', ''myurlhere'',
>> {asynchronous:true, evalScripts:true}); return false;">Testing
>> Ajax</a>
>>
>
>
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
>
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails
Hi,
Thanks so much to everyone. I am starting to understand the Ajax
calls a bit better. Infact
Ajax.PeriodicalUpdater is perfect for my application.
I wonder how i can better format the results from clitest.php . here
is my script
ajax-text.html
<html>
<head>
<script type="text/javascript"
src="javascript/prototype.js"></script>
<script type="text/javascript">
window.onload=function()
{new Ajax.PeriodicalUpdater(''number'',
''clitest.php'',{asynchronous:true, evalScripts:true,
frequency:5});
return false;
}
</script>
</head>
<body>
<div id="counter">
<p id="number"></p>
</div>
</body>
</html>
and here is what is returned by clitest.php
<?xml version="1.0" ?>
<article>
<header>Some Title</header>
<body>Blah blah some content here.</body>
<link>http://www.somelink.com</link>
</article>
What I would like to do is format the header, body and link into ajax-text.html
<div id="counter">
<p id="number"><h1>Some Title</h1><a
href="http://www.somelink.com">Blah blah some content
here.</a></p>
</div>
Any help is appreciated,
Chuck
> >
> > On Jul 25, 2005, at 7:48 AM, Chris Roos wrote:
> >
> >
> > <a href="#" onclick="new
Ajax.Updater(''mydivhere'', ''myurlhere'',
> {asynchronous:true, evalScripts:true}); return false;">Testing
Ajax</a>