|
|||||||
| JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...) |
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to access calling object in OnSuccess/OnFailure?
Hi guys,
I'm making this ajax call: Code:
new Ajax.Request(url, {
method: 'get',
onSuccess: function(transport) {
this.contextReady = true;
},
onFailure: function(transport) {
this.contextReady = false;
}
});
How can I update the right this.contextReady? Thanks for any hints! |
|
#2
|
|||
|
|||
|
Create a variable reference to the 'this' object:
Code:
var myObj = {
contextReady : false,
makeRequest : function (url) {
var obj = this; //holder to reference myObj's 'this'
new Ajax.Request(url, {
method: 'get',
onSuccess: function(transport) {
obj.contextReady = true;
},
onFailure: function(transport) {
obj.contextReady = false;
}
});
}
};
|
![]() |
| Bookmarks |
| Tags |
| ajax, onfailure, onsuccess |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|