I want to have a global object that can be updated via Ajax:
var globalObject;
function updateObject (id) {
new Ajax.Request('url', { parameters: {id: id}, onSuccess:
function(transport) {
globalObject = transport.responseText.evalJSON();
}});
}
That never seems to work though, why not?
Thanks!
on 2008-06-26 09:26
on 2008-06-26 13:47
That should actually work unless there's another "globalObject" in the scope of callback function. Are you sure a proper response comes from the server? - kangax
on 2008-06-26 18:19
When are you verifying its value, it will be undefined until the ajax request has come back to the onSuccess handler. -- Matt Foster Ajax Engineer Nth Penguin, LLC http://www.nthpenguin.com