Hi, I''m making an AJAX call to load prototype.js I then call eval on the request''s response text ie success: function(req){ eval(req.responseText) } This works to load most javascript, but prototype in particular is confusing me. This error is getting thrown: Node has no properties by the following prototype source (line 1526): if (!window.Node) var Node = { }; if (!Node.ELEMENT_NODE) { Debug statements immediately before this section show window.Node != null Node == null As far as I understand javascript that should be impossible since window.Node == Node as long as you''re operating at the base level name space, ie window, not in a function etc. Obviously none of these shenanigans show up when I load prototype normally with a script tag. Is it really possible that eval is behaving differently than the javascript interpreter? Isn''t it just a hook into the javascript interpreter? Thanks for the help, this is driving me nuts with curiosity! Carl --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Yes, eval() is a hook into the interpreter - BUT, since you''re doing your eval() in the context of an Ajax callback, all the outer variable assignments will define variables local to that function! So, definitely will not work: function() { eval("var x = 42"); } x === undefined! eval("var x = 42"); x === 42 -Fred On Thu, Jun 26, 2008 at 3:33 PM, dcx <Youngblood.Carl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Obviously none of these shenanigans show up when I load prototype > normally with a script tag. Is it really possible that eval is > behaving differently than the javascript interpreter? Isn''t it just a > hook into the javascript interpreter? > > Thanks for the help, this is driving me nuts with curiosity!-- Science answers questions; philosophy questions answers. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Oops: more explicit here: function f() { eval("var x = 42"); } f(); x === undefined On Thu, Jun 26, 2008 at 3:37 PM, Frederick Polgardy <fred-SMQUYeM9IBBWk0Htik3J/w@public.gmane.org> wrote:> Yes, eval() is a hook into the interpreter - BUT, since you''re doing your > eval() in the context of an Ajax callback, all the outer variable > assignments will define variables local to that function! So, definitely > will not work: > > function() { > eval("var x = 42"); > } > > x === undefined! > > eval("var x = 42"); > > x === 42 > > -Fred > > > On Thu, Jun 26, 2008 at 3:33 PM, dcx <Youngblood.Carl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Obviously none of these shenanigans show up when I load prototype >> normally with a script tag. Is it really possible that eval is >> behaving differently than the javascript interpreter? Isn''t it just a >> hook into the javascript interpreter? >> >> Thanks for the help, this is driving me nuts with curiosity! > > > -- > Science answers questions; philosophy questions answers.-- Science answers questions; philosophy questions answers. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick, I am extremely obliged by your quick and clear response. I feel like such a noob for not seeing that. Thanks again! Carl On Jun 26, 3:38 pm, "Frederick Polgardy" <f...-SMQUYeM9IBBWk0Htik3J/w@public.gmane.org> wrote:> Oops: more explicit here: > > function f() { > eval("var x = 42"); > > } > > f(); > x === undefined > > On Thu, Jun 26, 2008 at 3:37 PM, Frederick Polgardy <f...-SMQUYeM9IBBWk0Htik3J/w@public.gmane.org> > wrote: > > > > > Yes, eval() is a hook into the interpreter - BUT, since you''re doing your > > eval() in the context of an Ajax callback, all the outer variable > > assignments will define variables local to that function! So, definitely > > will not work: > > > function() { > > eval("var x = 42"); > > } > > > x === undefined! > > > eval("var x = 42"); > > > x === 42 > > > -Fred > > > On Thu, Jun 26, 2008 at 3:33 PM, dcx <Youngblood.C...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >> Obviously none of these shenanigans show up when I load prototype > >> normally with a script tag. Is it really possible that eval is > >> behaving differently than the javascript interpreter? Isn''t it just a > >> hook into the javascript interpreter? > > >> Thanks for the help, this is driving me nuts with curiosity! > > > -- > > Science answers questions; philosophy questions answers. > > -- > Science answers questions; philosophy questions answers.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---