Hi Rodrigo,

I see two problems there, and separately I have two suggestions.

The problems are:

1. You're using the onComplete handler.  onComplete is fired when the
request is complete for *any reason*, even if it failed.  You probably
only want to do this when the request is successful, which is the
onSuccess handler.  (You probably also want to have an onFailure
handler so you can tell the user that the request failed; it may be
worth looking at this article[1] on the unofficial wiki.)

2. You don't want the 'this' in this line:

    $('conteudo').innerHTML = this.originalRequest.responseText;

Just use:

    $('conteudo').innerHTML = originalRequest.responseText;

...or even better, using Element#update[2]:


Okay, the suggestions:

A) Your variable name "originalRequest" is misleading, because it's
not the request.  It's an Ajax.Response object.  I suggest the name
"response". :-)

B) Use Ajax.Updater[3] instead of Ajax.Request.  Ajax.Updater does
almost exactly what you're doing.

[1] http://proto-scripty.wikidot.com/prototype:how-to-bulletproof-ajax-requests
[2] http://prototypejs.org/api/element/update
[3] http://prototypejs.org/api/ajax/updater

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

On Jun 8, 4:03 am, Rodrigo Ramos <rodrigoramos...@gmail.com> wrote:
> Hey guys,
> i'm having a trouble with the Ajax.Request method in my code. Could
> you guys help me out?!
> Here is the thing: I have a simple html website and i'm just trying to
> "change" things using Ajax. The problem is that its working only in
> FF. On IE simply doesnt work. And, as usual, no error message =S. I'm
> using the version.
> I've already tried to debbug printing some alert's inside the method
> but nothing happend. The object its created (i've put an alert on
> "onCreate") but the .html file never show on screen.
> You guys have any ideia of what could it be?
> code:
> function ajax(url){
>         var myAjax = new Ajax.Request('conteudo/'+url+'.html', {
>                 method : 'get',
>                 onComplete: function (originalRequest){
>                         $('conteudo').innerHTML = 
> this.originalRequest.responseText;
>                 }
>         });
> }
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 
For more options, visit this group at 

Reply via email to