I am using the firebug plugin to debug my javascript code, and I get the following message while debugging. Anyone familiar with this error? See my code below: <title>My Test </title> <script src="json.js" type="text/javascript"></script> <script src="prototype.js" type="text/javascript"></script> <style type="text/css"> * {font-family:Tahoma,Arial,sans-serif;} #helloTitle{color: #48f;} .sidebar { background-color: #adf; color: Navy; border: solid blue 1px; width: 180px; height: 200px; padding: 2px; margin: 3px; float: left; } </style> <script type=''text/javascript''> window.onload = function() { debugger; $(''helloBtn'').onclick = function() { var name=$(''helloTxt'').value; new Ajax.Request( "Default3.aspx?name = "+encodeURI(name), { method:"get", onComplete:function(xhr) { var responseObj = eval("("+xhr.responseText +")"); update(responseObj); } } ); }; }; function update(obj) { $(''helloTitle'').innerHTML = "<h1>Hello, <b><i>" + obj.name + "</i></b></h1>"; var likesHTML = "<h5>"+obj.initial+" likes...</h5><hr/>"; for(var i=0;i<obj.likes.length;i++){ likesHTML+=obj.likes[i]+"<br/>"; } $(''likesList'').innerHTML =likesHTML; var recipeHTML="<h5>"+obj.initial+"''s favorite recipe</ h5>"; for (key in obj.ingredients){ recipeHTML+=key+" : "+obj.ingredients[key]+"<br/>"; } $(''ingrList'').innertHTML=recipeHTML; } --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I am using the firebug plugin to debug my javascript code, and I get the following message while debugging. Anyone familiar with this error? See my code below: <title>My Test </title> <script src="json.js" type="text/javascript"></script> <script src="prototype.js" type="text/javascript"></script> <style type="text/css"> * {font-family:Tahoma,Arial,sans-serif;} #helloTitle{color: #48f;} .sidebar { background-color: #adf; color: Navy; border: solid blue 1px; width: 180px; height: 200px; padding: 2px; margin: 3px; float: left; } </style> <script type=''text/javascript''> window.onload = function() { debugger; $(''helloBtn'').onclick = function() { var name=$(''helloTxt'').value; new Ajax.Request( "Default3.aspx?name = "+encodeURI(name), { method:"get", onComplete:function(xhr) { var responseObj = eval("("+xhr.responseText +")"); update(responseObj); } } ); }; }; function update(obj) { $(''helloTitle'').innerHTML = "<h1>Hello, <b><i>" + obj.name + "</i></b></h1>"; var likesHTML = "<h5>"+obj.initial+" likes...</h5><hr/>"; for(var i=0;i<obj.likes.length;i++){ likesHTML+=obj.likes[i]+"<br/>"; } $(''likesList'').innerHTML =likesHTML; var recipeHTML="<h5>"+obj.initial+"''s favorite recipe</ h5>"; for (key in obj.ingredients){ recipeHTML+=key+" : "+obj.ingredients[key]+"<br/>"; } $(''ingrList'').innertHTML=recipeHTML; } --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Tom Gregory
2007-Oct-25 18:46 UTC
Re: ""throw $continue" is deprecated, use "return" instead"
The message is just what it says .. don''t use "throw $continue", use "return". It''s part of the Enumerable mix-in. I don''t see where it might be coming from ... but it also looks like there might be more code we''re not seeing. What''s json.js? The newer versions of Prototype have JSON support built in, so you won''t need external json libraries. The one from json.org, in particular, is incompatible with Prototype. It''s possible the error is coming from your use of for ... in. (Without knowing more about the object you''re passing, it''s hard to tell.) Is obj.ingredients an Array or a Hash? Either way, you may (depending on your object) be better off with using "each" instead of for ... in. http://prototypejs.org/api/enumerable/each As an aside, there are some Prototype conventions that might clean up your code a little bit. These changes aren''t essential (it''s mostly a style thing), but they will help protect you from some odd cross- browser issues, and will make your code more readable by Prototype folks. Instead of: var name=$(''helloTxt'').value; Do: var name=$F(''helloTxt''); Instead of new Ajax.Request( "Default3.aspx?name = "+encodeURI(name), { method:"get", Do: new Ajax.Request( "Default3.aspx", { parameters: {name: name}, method:"get", // This does encodeURIComponent internally, which is the function you should be using anyway (not encodeURI). Instead of: $(''helloTitle'').innerHTML = someString; Do: ${helloTitle'').update(someString); It also looks like you could benefit from using Prototype''s Template object: http://prototypejs.org/api/template I don''t know that I can get you further toward answering your question ... if you do some cleanup and are still having the same problem, please provide the full error message (including file, line #), or (even better) post a *reduced* sample online. TAG On Oct 25, 2007, at 11:57 AM, carlos wrote:> > I am using the firebug plugin to debug my javascript code, and I get > the following message while debugging. Anyone familiar with this > error? > > See my code below: > > <title>My Test </title> > > <script src="json.js" type="text/javascript"></script> > <script src="prototype.js" type="text/javascript"></script> > > <style type="text/css"> > * {font-family:Tahoma,Arial,sans-serif;} > #helloTitle{color: #48f;} > .sidebar > { > background-color: #adf; > color: Navy; > border: solid blue 1px; > width: 180px; > height: 200px; > padding: 2px; > margin: 3px; > float: left; > } > </style> > > <script type=''text/javascript''> > window.onload = function() { > debugger; > $(''helloBtn'').onclick = function() { > var name=$(''helloTxt'').value; > new Ajax.Request( > "Default3.aspx?name = "+encodeURI(name), > { > method:"get", > onComplete:function(xhr) { > var responseObj = eval("("+xhr.responseText > +")"); > update(responseObj); > } > } > ); > }; > }; > > function update(obj) { > $(''helloTitle'').innerHTML = "<h1>Hello, <b><i>" + obj.name > + "</i></b></h1>"; > var likesHTML = "<h5>"+obj.initial+" likes...</h5><hr/>"; > for(var i=0;i<obj.likes.length;i++){ > likesHTML+=obj.likes[i]+"<br/>"; > } > $(''likesList'').innerHTML =likesHTML; > var recipeHTML="<h5>"+obj.initial+"''s favorite recipe</ > h5>"; > for (key in obj.ingredients){ > recipeHTML+=key+" : "+obj.ingredients[key]+"<br/>"; > } > $(''ingrList'').innertHTML=recipeHTML; > }--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks Tom. I just started learning about prototype, and your suggestions were beneficial. I will try making your requested changes, and i''ll post a more detailed error listing if I get the message again. Thanks again On Oct 25, 1:46 pm, Tom Gregory <t...-PGZyUNKar/Q@public.gmane.org> wrote:> The message is just what it says .. don''t use "throw $continue", use > "return". It''s part of the Enumerable mix-in. > > I don''t see where it might be coming from ... but it also looks like > there might be more code we''re not seeing. What''s json.js? The newer > versions of Prototype have JSON support built in, so you won''t need > external json libraries. The one from json.org, in particular, is > incompatible with Prototype. > > It''s possible the error is coming from your use of for ... in. > (Without knowing more about the object you''re passing, it''s hard to > tell.) Is obj.ingredients an Array or a Hash? Either way, you may > (depending on your object) be better off with using "each" instead of > for ... in.http://prototypejs.org/api/enumerable/each > > As an aside, there are some Prototype conventions that might clean up > your code a little bit. These changes aren''t essential (it''s mostly a > style thing), but they will help protect you from some odd cross- > browser issues, and will make your code more readable by Prototype > folks. > > Instead of: > var name=$(''helloTxt'').value; > Do: > var name=$F(''helloTxt''); > > Instead of > new Ajax.Request( > "Default3.aspx?name = "+encodeURI(name), > { > method:"get", > Do: > new Ajax.Request( > "Default3.aspx", > { > parameters: {name: name}, > method:"get", > // This does encodeURIComponent internally, which is the function you > should be using anyway (not encodeURI). > > Instead of: > $(''helloTitle'').innerHTML = someString; > Do: > ${helloTitle'').update(someString); > > It also looks like you could benefit from using Prototype''s Template > object:http://prototypejs.org/api/template > > I don''t know that I can get you further toward answering your > question ... if you do some cleanup and are still having the same > problem, please provide the full error message (including file, line > #), or (even better) post a *reduced* sample online. > > TAG > > On Oct 25, 2007, at 11:57 AM, carlos wrote: > > > > > I am using the firebug plugin to debug my javascript code, and I get > > the following message while debugging. Anyone familiar with this > > error? > > > See my code below: > > > <title>My Test </title> > > > <script src="json.js" type="text/javascript"></script> > > <script src="prototype.js" type="text/javascript"></script> > > > <style type="text/css"> > > * {font-family:Tahoma,Arial,sans-serif;} > > #helloTitle{color: #48f;} > > .sidebar > > { > > background-color: #adf; > > color: Navy; > > border: solid blue 1px; > > width: 180px; > > height: 200px; > > padding: 2px; > > margin: 3px; > > float: left; > > } > > </style> > > > <script type=''text/javascript''> > > window.onload = function() { > > debugger; > > $(''helloBtn'').onclick = function() { > > var name=$(''helloTxt'').value; > > new Ajax.Request( > > "Default3.aspx?name = "+encodeURI(name), > > { > > method:"get", > > onComplete:function(xhr) { > > var responseObj = eval("("+xhr.responseText > > +")"); > > update(responseObj); > > } > > } > > ); > > }; > > }; > > > function update(obj) { > > $(''helloTitle'').innerHTML = "<h1>Hello, <b><i>" + obj.name > > + "</i></b></h1>"; > > var likesHTML = "<h5>"+obj.initial+" likes...</h5><hr/>"; > > for(var i=0;i<obj.likes.length;i++){ > > likesHTML+=obj.likes[i]+"<br/>"; > > } > > $(''likesList'').innerHTML =likesHTML; > > var recipeHTML="<h5>"+obj.initial+"''s favorite recipe</ > > h5>"; > > for (key in obj.ingredients){ > > recipeHTML+=key+" : "+obj.ingredients[key]+"<br/>"; > > } > > $(''ingrList'').innertHTML=recipeHTML; > > }--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Tobie Langel
2007-Oct-25 23:30 UTC
Re: ""throw $continue" is deprecated, use "return" instead"
Hi Carlos, Two thing you need to be aware of: 1. $continue has been deprecated. You shouldn''t be using it. As the error message rightfully explains, you should use return in your iterator instead. 2. Prototype is NOT compatible with json.js. Please read our tutorial on JSON (http://prototypejs.org/learn/json) to find about why and learn how to use Prototype''s own built-in JSON support instead. That said, welcome aboard and happy prototyping! Tobie On Oct 25, 9:04 pm, carlos <carlos4ubu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks Tom. > > I just started learning about prototype, and your suggestions were > beneficial. I will try making your requested changes, and i''ll post a > more detailed error listing if I get the message again. > > Thanks again > > On Oct 25, 1:46 pm, Tom Gregory <t...-PGZyUNKar/Q@public.gmane.org> wrote: > > > The message is just what it says .. don''t use "throw $continue", use > > "return". It''s part of the Enumerable mix-in. > > > I don''t see where it might be coming from ... but it also looks like > > there might be more code we''re not seeing. What''s json.js? The newer > > versions of Prototype have JSON support built in, so you won''t need > > external json libraries. The one from json.org, in particular, is > > incompatible with Prototype. > > > It''s possible the error is coming from your use of for ... in. > > (Without knowing more about the object you''re passing, it''s hard to > > tell.) Is obj.ingredients an Array or a Hash? Either way, you may > > (depending on your object) be better off with using "each" instead of > > for ... in.http://prototypejs.org/api/enumerable/each > > > As an aside, there are some Prototype conventions that might clean up > > your code a little bit. These changes aren''t essential (it''s mostly a > > style thing), but they will help protect you from some odd cross- > > browser issues, and will make your code more readable by Prototype > > folks. > > > Instead of: > > var name=$(''helloTxt'').value; > > Do: > > var name=$F(''helloTxt''); > > > Instead of > > new Ajax.Request( > > "Default3.aspx?name = "+encodeURI(name), > > { > > method:"get", > > Do: > > new Ajax.Request( > > "Default3.aspx", > > { > > parameters: {name: name}, > > method:"get", > > // This does encodeURIComponent internally, which is the function you > > should be using anyway (not encodeURI). > > > Instead of: > > $(''helloTitle'').innerHTML = someString; > > Do: > > ${helloTitle'').update(someString); > > > It also looks like you could benefit from using Prototype''s Template > > object:http://prototypejs.org/api/template > > > I don''t know that I can get you further toward answering your > > question ... if you do some cleanup and are still having the same > > problem, please provide the full error message (including file, line > > #), or (even better) post a *reduced* sample online. > > > TAG > > > On Oct 25, 2007, at 11:57 AM, carlos wrote: > > > > I am using the firebug plugin to debug my javascript code, and I get > > > the following message while debugging. Anyone familiar with this > > > error? > > > > See my code below: > > > > <title>My Test </title> > > > > <script src="json.js" type="text/javascript"></script> > > > <script src="prototype.js" type="text/javascript"></script> > > > > <style type="text/css"> > > > * {font-family:Tahoma,Arial,sans-serif;} > > > #helloTitle{color: #48f;} > > > .sidebar > > > { > > > background-color: #adf; > > > color: Navy; > > > border: solid blue 1px; > > > width: 180px; > > > height: 200px; > > > padding: 2px; > > > margin: 3px; > > > float: left; > > > } > > > </style> > > > > <script type=''text/javascript''> > > > window.onload = function() { > > > debugger; > > > $(''helloBtn'').onclick = function() { > > > var name=$(''helloTxt'').value; > > > new Ajax.Request( > > > "Default3.aspx?name = "+encodeURI(name), > > > { > > > method:"get", > > > onComplete:function(xhr) { > > > var responseObj = eval("("+xhr.responseText > > > +")"); > > > update(responseObj); > > > } > > > } > > > ); > > > }; > > > }; > > > > function update(obj) { > > > $(''helloTitle'').innerHTML = "<h1>Hello, <b><i>" + obj.name > > > + "</i></b></h1>"; > > > var likesHTML = "<h5>"+obj.initial+" likes...</h5><hr/>"; > > > for(var i=0;i<obj.likes.length;i++){ > > > likesHTML+=obj.likes[i]+"<br/>"; > > > } > > > $(''likesList'').innerHTML =likesHTML; > > > var recipeHTML="<h5>"+obj.initial+"''s favorite recipe</ > > > h5>"; > > > for (key in obj.ingredients){ > > > recipeHTML+=key+" : "+obj.ingredients[key]+"<br/>"; > > > } > > > $(''ingrList'').innertHTML=recipeHTML; > > > }--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---