Oh, looks like I forgot to add the quotes around "get"...

Colin

Esther wrote:
Colin,
You were right. By placing the script after the div, the content
finaly got updated.
However I tryed your shortened code but it didn't work. I don't know
why, maybe the onComplete does make a difference. By all logic it
should work.

Thanks for the explanation and the tip about changing the
responseText.


On Feb 18, 11:23 pm, Colin Mollenhour <[EMAIL PROTECTED]>
wrote:
  
Ajax.Updater is basically a wrapper for Ajax.Request which calls an
insertion function (default is Element.update) on the element passed, so
your onComplete function is not necessary. You are basically updating
that element twice but I think it should still update.. perhaps the
other problem is that your script is running before the content div is
loaded? Try placing your script block at the end of the body or at least
anywhere after the <div>. Also there is usually no reason to store the
Ajax requests in a variable. Your Ajax.Updater call could then look like
this:

new Ajax.Updater('content',weekdays[weekday]+'.htm',{method: get});

or, if you want to do something with the responseText before updating:

new Ajax.Updater('content',weekdays[weekday]+'.htm',{
    method: get,
    insertion: function(element,update){
        alert(element.id+' gets '+update);
        Element.update(element,update);
    }

});

Colin

[EMAIL PROTECTED] wrote:
    
Hi,
      
I'm new to Prototype and I'm trying to use Ajax.Updater to update a
pege with new content depending on the day of the week. I'm doing this
with an html for each day, but maybe you could suggest how to do this
with a single xml file?
In any case, my problem is that the code below doesn't work and i
don't know why.
In the function showResponse() the alert displays the html contents,
so the updater is working correctly only that the 'content' container
is not displaying.
What am I doing wrong?
      
<html>
<head>
<script src="" type="text/_javascript_"></
script>
<script language="_javascript_" type="text/_javascript_">
today=new Date();
weekday=today.getDay();
weekdays=['sunday','monday','tuesday','wednesday','thursday','friday','saturday'];
var ajax = new Ajax.Updater('content',weekdays[0]+'.htm',
         {                // options
             method:'get',
             onComplete: showResponse
             });
      
function showResponse(req)
{
alert(req.responseText);
$('content').innerHTML = req.responseText;
      
}
      
</script>
</head>
<body>
<div id="content"></div>
</body>
</html>
      




  

--~--~---------~--~----~------------~-------~--~----~
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