On 6/14/06, Kevin Old <[EMAIL PROTECTED]> wrote:
Hello everyone,Just a note, I have to pass my JSON in the response body. I'm aware of the X-JSON header, but am passing too much data to use it. No problem and I have code that has it working well. While I'm getting my JSON data back and can do whatever I'd like with it in "setMakeVars", I'd like to set it to a global var "gljson" below, but it never gets set. Everything with the request is fine and there is data in the "json" var in "setMakeVars", but it's almost like "setMakeVars" doesn't have access to global vars. var gljson; var url = '/my/path/here'; var ajobj = new Ajax.Request( url, { method: 'get', onComplete: setMakeVars }); function setMakeVars (transport) { var json = eval(transport.responseText); gljson = json; } alert(gljson); // is undefined
Hi everyone, I've figured out that my variable was being set with the JSON data, but it was only "in scope" with the data inside the setMakeVars function. A friend said that in order to use this data I'd have to make the subsequent calls from within setMakeVars. I'm not sure that's a good idea. Here's what I'm trying to do. I'm building a multirecord (in place) edit form and have a need for the Ajax.InPlaceSelect [1,2] lists. It needs the data in two arrays, one for the keys, the other the values. Using the $H() function, I can do this, but since I plan to have 10 records per page (10 instances of the select list), it'd make sense to fetch the data once and store it in a global variable, right? Can this be done? [1] http://dev.rubyonrails.org/attachment/ticket/2667/Ajax.InPlaceSelect.3.js [2] http://wiki.script.aculo.us/scriptaculous/show/InPlaceSelect Any help is greatly appreciated! Kevin -- Kevin Old [EMAIL PROTECTED] _______________________________________________ Rails-spinoffs mailing list [email protected] http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
