Hi all, first post so please be gentle.
I have the following javascript defined (cut down for legibility)
function ATKWidget()
{
var m_Key;
this.draw = draw;
this.doDrawWidgetResponse = doDrawWidgetResponse;
function draw()
{
//Issue the AJAX request
var data = "output=json&key=" + this.m_Key;
var myAjax = new Ajax.Request(this.m_ATKLocation + "/
getwidgetdata.php", {method: ''post'', parameters: data,
onComplete:
this.doDrawWidgetResponse});
}
function doDrawWidgetResponse(originalRequest)
{
alert(originalRequest.responseText);
alert(this.m_Key);
}
}
and in the doDrawWidgetResponse the this.m_Key is undefined (when it
should have a value in it. Its certainly defined in the draw()
function :)
Am I doing something wrong with the way I am calling the onComplete or
have I stuffed something else up.
The request responds correctly and I get what I am expecting in
originalRequest.responseText but it seems to be a new instance of
ATKWidget.
Thanks in advance for any help.
Mike Marshall
Lexalytics Inc.
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
hi,
I assume you use prototype as the AJAX framework and you get an error like:
''this has no properties''.
I had the same problem about half a year ago.
The solution is the "bind()" function:
var myAjax = new Ajax.Request(this.m_ATKLocation + "/
getwidgetdata.php", {method: ''post'', parameters: data,
onComplete:
this.doDrawWidgetResponse.bind(this)});
hope this helps
Bastian
On 9/2/07, Mike Marshall
<myke.marshall-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
>
> Hi all, first post so please be gentle.
>
> I have the following javascript defined (cut down for legibility)
> function ATKWidget()
> {
> var m_Key;
> this.draw = draw;
> this.doDrawWidgetResponse = doDrawWidgetResponse;
>
> function draw()
> {
> //Issue the AJAX request
> var data = "output=json&key=" + this.m_Key;
> var myAjax = new Ajax.Request(this.m_ATKLocation + "/
> getwidgetdata.php", {method: ''post'', parameters:
data, onComplete:
> this.doDrawWidgetResponse});
>
> }
>
> function doDrawWidgetResponse(originalRequest)
> {
> alert(originalRequest.responseText);
> alert(this.m_Key);
> }
> }
>
> and in the doDrawWidgetResponse the this.m_Key is undefined (when it
> should have a value in it. Its certainly defined in the draw()
> function :)
>
> Am I doing something wrong with the way I am calling the onComplete or
> have I stuffed something else up.
>
> The request responds correctly and I get what I am expecting in
> originalRequest.responseText but it seems to be a new instance of
> ATKWidget.
>
> Thanks in advance for any help.
>
> Mike Marshall
> Lexalytics Inc.
>
>
> >
>
--
--
spread the word ... see www.browsehappy.com ;o)
Calvin: Weekends don''t count unless you spend them doing something
completely pointless.
Join the Greater IBM Connection (
http://www.xing.com/premiumgroup-6291.d26b7d)
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
Curses, should have said I was using Prototype.
That works perfectly, thanks very much for the help.
Mike Marshall
Lexalytics Inc.
From: rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
[mailto:rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf
Of Bastian Feder
Sent: 02 September 2007 09:40
To: rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: [Rails-spinoffs] Re: Possible Dumb Question
hi,
I assume you use prototype as the AJAX framework and you get an error like:
''this has no properties''.
I had the same problem about half a year ago.
The solution is the "bind()" function:
var myAjax = new Ajax.Request(this.m_ATKLocation + "/
getwidgetdata.php", {method: ''post'', parameters: data,
onComplete:
this.doDrawWidgetResponse.bind(this)});
hope this helps
Bastian
On 9/2/07, Mike Marshall
<myke.marshall-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Hi all, first post so please be gentle.
I have the following javascript defined (cut down for legibility)
function ATKWidget()
{
var m_Key;
this.draw = draw;
this.doDrawWidgetResponse = doDrawWidgetResponse;
function draw()
{
//Issue the AJAX request
var data = "output=json&key=" + this.m_Key;
var myAjax = new Ajax.Request(this.m_ATKLocation + "/
getwidgetdata.php", {method: ''post'', parameters: data,
onComplete:
this.doDrawWidgetResponse});
}
function doDrawWidgetResponse(originalRequest)
{
alert(originalRequest.responseText);
alert(this.m_Key);
}
}
and in the doDrawWidgetResponse the this.m_Key is undefined (when it
should have a value in it. Its certainly defined in the draw()
function :)
Am I doing something wrong with the way I am calling the onComplete or
have I stuffed something else up.
The request responds correctly and I get what I am expecting in
originalRequest.responseText but it seems to be a new instance of
ATKWidget.
Thanks in advance for any help.
Mike Marshall
Lexalytics Inc.
Join the Greater IBM Connection
(http://www.xing.com/premiumgroup-6291.d26b7d)
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---