Hi,

There are a couple of problems there.  The first and biggest problem
is that your clock.html file *isn't* getting the server's time, it's
getting the client's time.  You're running client-side code to output
the time to the document as it's being rendered in the browser.  The
second problem is that you can't use document.write in script tags in
content you're going to retrieve and put on the page via
PeriodicalUpdater (or Element#update or anything like them).  But see
the first point, you don't want to anyway.

You need to create something that runs *on the server* and outputs the
time, and then plop that into the appropriate location on your page.

HTH,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available

On Apr 27, 11:07 am, Palastina Uber Alles <ala...@gmail.com> wrote:
> Hello everyone,
> I am new to prototype, and I am trying to implement a simple ajax
> request
> I wrote the index.html file, and the clock.html file
>
> index.html
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> <html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
> <head>
> <meta http-equiv="content-type" content="text/html; charset=utf-8" />
> <title> Test Page </title>
> <script type="text/javascript" src="../prototype.js"></script>
> <script>
>         function getClock() {
>                 var url = 'data/clock.html';
>                 var myAjax = new Ajax.PeriodicalUpdater(
>                         'clockArea',
>                         url,
>                         {
>                                 method: 'get',
>                                 frequency: 2,
>                                 onFailure: function(resp) {alert("Failure : "+
> resp.statusTest,"test");},
>                                 onException : function(resp, 
> exception){alert("exception "+
> exception,"test");}
>                         });
>                 }
> </script>
> </head>
> <body>
>         <input type="button" value="Test" onclick="getClock();"/><br/> <br/>
> <br/>
>         <p><div id="clockArea"></div></p>
> </body>
> </html>
>
> and the clock.html
>
> <html>
> <head>
> <script type="text/javascript">
> function display()
> {
>         var myscriptTime  = new Date();
>         document.write(myscriptTime)
>
> }
>
> </script>
> </head>
> <body onload=display()>
>
> </body>
> </html>
>
> clock.html displays the date correctly, but when I click the btn in
> the first file the time is not displayed
> and there is no errors. "onSuccess it alerts a msg"
>
> any body can help me please.
--~--~---------~--~----~------------~-------~--~----~
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 prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to