Hi, I''m using PHP to fill my parameterlist for Autocompleter.Local as shown in the example (http://wiki.script.aculo.us/scriptaculous/show/Autocompleter.Local). <script type="text/javascript"> new Autocompleter.Local(''recipeNameAlternative'', ''rezept_list'', [ <?php $ende = count($rezept_vorgabe); for ($i=0;$i<$ende;$i++) { echo ''\''''.$rezept_vorgabe[$i].''\''''; if($i != $ende-1) { echo ","; } } ?> ], {}); </script> If the content of $rezept_vorgabe is over 30 elements long, my JavaScript-Console returns the error "missing ] after element list". AutoCompletion will not work!? Can someone give me a hint? sebastian -- mailto:kurt-cPcqOTmdTlv31zTM6d8ziw@public.gmane.org 0179 7923088
On 2/9/06, Sebastian Kurt <skurt-Mmb7MZpHnFY@public.gmane.org> wrote:> Hi, > I''m using PHP to fill my parameterlist for Autocompleter.Local as > shown in the example > (http://wiki.script.aculo.us/scriptaculous/show/Autocompleter.Local). > > <script type="text/javascript"> > new Autocompleter.Local(''recipeNameAlternative'', ''rezept_list'', [ > <?php $ende = count($rezept_vorgabe); > for ($i=0;$i<$ende;$i++) { > echo ''\''''.$rezept_vorgabe[$i].''\''''; > if($i != $ende-1) { > echo ","; > } > } ?> > ], {}); > </script> > > If the content of $rezept_vorgabe is over 30 elements long, my > JavaScript-Console returns the error "missing ] after element list". > AutoCompletion will not work!? > > Can someone give me a hint?Do you have a live site we can look at? Do any of your elements contain a ''? It would need to be escaped (\\\''). Todd
On Thursday 09 February 2006 15:13, Sebastian Kurt wrote:> Hi, > I''m using PHP to fill my parameterlist for Autocompleter.Local as > shown in the example > (http://wiki.script.aculo.us/scriptaculous/show/Autocompleter.Local). > > <script type="text/javascript"> > new Autocompleter.Local(''recipeNameAlternative'', ''rezept_list'', [ > <?php $ende = count($rezept_vorgabe); > for ($i=0;$i<$ende;$i++) { > echo ''\''''.$rezept_vorgabe[$i].''\''''; > if($i != $ende-1) { > echo ","; > } > } ?> > ], {}); > </script> > > If the content of $rezept_vorgabe is over 30 elements long, my > JavaScript-Console returns the error "missing ] after element list". > AutoCompletion will not work!?something is probably wrong with one of the elements in the list. instead of blindly writing out the array, you might want to find a php JSON module or extension or function or whatever, and you just generate an array, convert it to json, and drop it in there. Then you can be certain (unless the JSON creation is buggy) that the array will work. I currently use the perl JSON module for a similar function, and I often have thousands of elements in the array without problems. If you aren''t down for that, then I am with Todd that we need to see the output of the php code you have shown us. I''m not good enough with php to be able to think of an example where your code would produce broken javascript, but I''m almost certain that''s what''s happening. -Jeremy -- Jeremy Kitchen ++ kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org In the beginning was The Word and The Word was Content-type: text/plain -- The Word of Bob. _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Todd Ross schrieb:> On 2/9/06, Sebastian Kurt <skurt-Mmb7MZpHnFY@public.gmane.org> wrote: >> Hi, >> I''m using PHP to fill my parameterlist for Autocompleter.Local as >> shown in the example >> (http://wiki.script.aculo.us/scriptaculous/show/Autocompleter.Local). >> >> <script type="text/javascript"> >> new Autocompleter.Local(''recipeNameAlternative'', ''rezept_list'', [ >> <?php $ende = count($rezept_vorgabe); >> for ($i=0;$i<$ende;$i++) { >> echo ''\''''.$rezept_vorgabe[$i].''\''''; >> if($i != $ende-1) { >> echo ","; >> } >> } ?> >> ], {}); >> </script> >> >> If the content of $rezept_vorgabe is over 30 elements long, my >> JavaScript-Console returns the error "missing ] after element list". >> AutoCompletion will not work!? >> >> Can someone give me a hint? > > Do you have a live site we can look at? Do any of your elements > contain a ''? It would need to be escaped (\\\''). >okay, i can. http://lekapidia.ml-its.de/formtest/test.php I change ''\''''.$rezept_vorgabe[$i].''\'''' to "''".$region_vorgabe[$i]."''" in PHP, but no Changes. thanks for more help sebastian -- mailto:kurt-cPcqOTmdTlv31zTM6d8ziw@public.gmane.org 0179 7923088
Your PHP-built list has quotes in it which is breaking the JS. Try: ''\''''.str_replace("''", "\\''", $rezept_vorgabe[$i]).''\'''' Also you know you can loop through an array with http://www.php.net/foreach ? <?php $array = Array("foo", "bar", "baz", "boo"); foreach ($array as $value) { echo $value."\n"; } ?> Prints: foo bar baz boo You should use the JavaScript console in Firefox 1.5, it alerts you to errors like this. I discovered your error by using a syntax highlighting editor such as Gvim (http://www.vim.org). -Rob Sebastian Kurt wrote:> Todd Ross schrieb: >> On 2/9/06, Sebastian Kurt <skurt-Mmb7MZpHnFY@public.gmane.org> wrote: >>> Hi, >>> I''m using PHP to fill my parameterlist for Autocompleter.Local as >>> shown in the example >>> (http://wiki.script.aculo.us/scriptaculous/show/Autocompleter.Local). >>> >>> <script type="text/javascript"> >>> new Autocompleter.Local(''recipeNameAlternative'', ''rezept_list'', [ >>> <?php $ende = count($rezept_vorgabe); >>> for ($i=0;$i<$ende;$i++) { >>> echo ''\''''.$rezept_vorgabe[$i].''\''''; >>> if($i != $ende-1) { >>> echo ","; >>> } >>> } ?> >>> ], {}); >>> </script> >>> >>> If the content of $rezept_vorgabe is over 30 elements long, my >>> JavaScript-Console returns the error "missing ] after element list". >>> AutoCompletion will not work!? >>> >>> Can someone give me a hint? >> >> Do you have a live site we can look at? Do any of your elements >> contain a ''? It would need to be escaped (\\\''). >> > > okay, i can. http://lekapidia.ml-its.de/formtest/test.php > > I change ''\''''.$rezept_vorgabe[$i].''\'''' to "''".$region_vorgabe[$i]."''" in > PHP, but no Changes. > > thanks for more help > sebastian >
thanks, i will try as far as I can. Robin Haswell schrieb:> Your PHP-built list has quotes in it which is breaking the JS. > Try: > ''\''''.str_replace("''", "\\''", $rezept_vorgabe[$i]).''\''''there are no '' in $rezept_vorgabe[$i]. i add the in the loop(PHP), see for ($i=0;$i<$ende;$i++) { echo "''".$region_vorgabe[$i]."''"; }> Also you know you can loop through an array with > http://www.php.net/foreach ? >yes, but this won''t solve my problem with comma (,) the at the end...> You should use the JavaScript console in Firefox 1.5, it alerts you to > errors like this.I have used it for a long time. The error "missing ] after element list" is out of it.> I discovered your error by using a syntax highlighting editor such as > Gvim (http://www.vim.org).I''m using Dreamweaver, so my syntax highlighting works well. -- mailto:kurt-cPcqOTmdTlv31zTM6d8ziw@public.gmane.org 0179 7923088
On 2/10/06, Sebastian Kurt <skurt-Mmb7MZpHnFY@public.gmane.org> wrote:> there are no '' in $rezept_vorgabe[$i]. i add the in the loop(PHP), see > for ($i=0;$i<$ende;$i++) { > echo "''".$region_vorgabe[$i]."''"; > }You are mistaken. ''Costa Rica'', ''Cote d''Ivoire'', ''Daenemark'' d''Ivoire needs to be escaped d\''Ivoire Todd
On Friday 10 February 2006 13:38, Sebastian Kurt wrote:> okay, i can. http://lekapidia.ml-its.de/formtest/test.php''Cote d''Ivoire'' you need to escape that inner single quote. Again, I would recommend using some sort of json module to handle this for you. -Jeremy -- Jeremy Kitchen ++ kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org In the beginning was The Word and The Word was Content-type: text/plain -- The Word of Bob. _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
I think that''s a bit overkill. My fix should work fine for anything that doesn''t include newlines. If this were my application I''d dump the data in a hidden <ul><li> or maybe as an xml string and parse it with the built-in DOM parser. Much better parse something in XML than *shudder* javascript. JS shouldn''t be used for heavy data processing because it burdens the client (IMO). -Rob Jeremy Kitchen wrote:> On Friday 10 February 2006 13:38, Sebastian Kurt wrote: > >> okay, i can. http://lekapidia.ml-its.de/formtest/test.php >> > > ''Cote d''Ivoire'' > > you need to escape that inner single quote. Again, I would recommend using > some sort of json module to handle this for you. > > -Jeremy > > > ------------------------------------------------------------------------ > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >
Robin Haswell wrote:> I think that''s a bit overkill. My fix should work fine for anything that > doesn''t include newlines. If this were my application I''d dump the data > in a hidden <ul><li> or maybe as an xml string and parse it with the > built-in DOM parser. Much better parse something in XML than *shudder* > javascript. JS shouldn''t be used for heavy data processing because it > burdens the client (IMO).Really? I would think that XML parsing in JS is much more burdensome than a native format. Would you replace all of you JS hashes with XML? -- Michael Peters Developer Plus Three, LP
Hm I may be mistaken. AFAIU JSON is a JS-compatible serialization form? Do browsers have built-in JSON deserializers? My the way, you''d be surprised at how efficient XML parsers are. In Python, it''s quicker to decode a list from XML than using the Pickle module (which is equivalent to PHP serialize()). IE probably even parses XML in kernel space, but that''s only a guess. -Rob Michael Peters wrote:> > Robin Haswell wrote: >> I think that''s a bit overkill. My fix should work fine for anything that >> doesn''t include newlines. If this were my application I''d dump the data >> in a hidden <ul><li> or maybe as an xml string and parse it with the >> built-in DOM parser. Much better parse something in XML than *shudder* >> javascript. JS shouldn''t be used for heavy data processing because it >> burdens the client (IMO). > > Really? I would think that XML parsing in JS is much more burdensome than a > native format. Would you replace all of you JS hashes with XML? >
Robin Haswell wrote:> Hm I may be mistaken. AFAIU JSON is a JS-compatible serialization form? > Do browsers have built-in JSON deserializers?Well, they''d have to if they have JS interpreters right? -- Michael Peters Developer Plus Three, LP
Michael Peters wrote:> > Robin Haswell wrote: >> Hm I may be mistaken. AFAIU JSON is a JS-compatible serialization form? >> Do browsers have built-in JSON deserializers? > > Well, they''d have to if they have JS interpreters right? >Um no, I mean can you convert a JSON object into a memory construct without parsing it with Javascript code. Hence, is there a built-in JSON deserializer (that isn''t written in JavaScript). As far as I am aware, JSON isn''t part of the javascript language specification. -Rob
No, but from I understand (don''t use JSON myself), it translates directly into Javascript objects when eval''ed. var myObj = eval(myJSONstring); -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Robin Haswell Sent: Friday, February 10, 2006 5:02 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] Length of parameters in Autocompleter.Local() Michael Peters wrote:> > Robin Haswell wrote: >> Hm I may be mistaken. AFAIU JSON is a JS-compatible serializationform?>> Do browsers have built-in JSON deserializers? > > Well, they''d have to if they have JS interpreters right? >Um no, I mean can you convert a JSON object into a memory construct without parsing it with Javascript code. Hence, is there a built-in JSON deserializer (that isn''t written in JavaScript). As far as I am aware, JSON isn''t part of the javascript language specification. -Rob _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs The information transmitted in this electronic mail is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers.
Oh I see. How interesting. Eval scares me heh. Well in which case you''d have to unit-test JSON vs XML to see which would be quicker. I have a feeling it''d be close though, and I know which one I''d pick if that was the case. -Rob Ryan Gahl wrote:> No, but from I understand (don''t use JSON myself), it translates > directly into Javascript objects when eval''ed. > > var myObj = eval(myJSONstring); > > -----Original Message----- > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Robin > Haswell > Sent: Friday, February 10, 2006 5:02 PM > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: Re: [Rails-spinoffs] Length of parameters in > Autocompleter.Local() > > Michael Peters wrote: > >> Robin Haswell wrote: >> >>> Hm I may be mistaken. AFAIU JSON is a JS-compatible serialization >>> > form? > >>> Do browsers have built-in JSON deserializers? >>> >> Well, they''d have to if they have JS interpreters right? >> >> > > > Um no, I mean can you convert a JSON object into a memory construct > without parsing it with Javascript code. Hence, is there a built-in JSON > > deserializer (that isn''t written in JavaScript). As far as I am aware, > JSON isn''t part of the javascript language specification. > > -Rob > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > The information transmitted in this electronic mail is intended only for the > person or entity to which it is addressed and may contain confidential, > proprietary, and/or privileged material. Any review, retransmission, > dissemination or other use of, or taking of any action in reliance upon, > this information by persons or entities other than the intended recipient > is prohibited. If you received this in error, please contact the sender and > delete the material from all computers. > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
thanks to all of you! this sign was the seed of all evil. move it into an JS-Array helped to solve it var temp_rezept_array = new Array(<?php echo count($rezept);?>); //Schleife <?php for ($i=0;$i<count($rezept);$i++) { echo "temp_rezept_array[".$i."] = \"".$rezept[$i]."\";\n"; } ?> thx sebastian Todd Ross schrieb:> On 2/10/06, Sebastian Kurt <skurt-Mmb7MZpHnFY@public.gmane.org> wrote: >> there are no '' in $rezept_vorgabe[$i]. i add the in the loop(PHP), see >> for ($i=0;$i<$ende;$i++) { >> echo "''".$region_vorgabe[$i]."''"; >> } > > You are mistaken. > > ''Costa Rica'', > ''Cote d''Ivoire'', > ''Daenemark'' > > d''Ivoire needs to be escaped d\''Ivoire > > Todd >-- mailto:kurt-cPcqOTmdTlv31zTM6d8ziw@public.gmane.org 0179 7923088
On Friday 10 February 2006 14:52, Robin Haswell wrote:> I think that''s a bit overkill. My fix should work fine for anything that > doesn''t include newlines. If this were my application I''d dump the data > in a hidden <ul><li> or maybe as an xml string and parse it with the > built-in DOM parser. Much better parse something in XML than *shudder* > javascript. JS shouldn''t be used for heavy data processing because it > burdens the client (IMO).errr.... no, I meant for him to take his php array, let''s say it''s this: $something = array ("bob", "larry", "frank"); then pass it to a JSON serializer, which will return a string, something like this: [''bob'', ''larry'', ''frank''] then drop that string in place where he currently has the broken javascript array. The advantage is, he doesn''t have to think about the escaping of strings and such, because the JSON serializer does it for him. I use this technique a lot in my own code for building an array/hash in perl and then ''converting'' it to javascript and dropping it inside a <script> tag. -Jeremy -Jeremy -- Jeremy Kitchen ++ kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org In the beginning was The Word and The Word was Content-type: text/plain -- The Word of Bob. _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
There are a few mistakes in this but yeah that would solve it for the meantime. -Rob Sebastian Kurt wrote:> thanks to all of you! this sign was the seed of all evil. > > move it into an JS-Array helped to solve it > > var temp_rezept_array = new Array(<?php echo count($rezept);?>); > //Schleife > <?php > for ($i=0;$i<count($rezept);$i++) { > echo "temp_rezept_array[".$i."] = \"".$rezept[$i]."\";\n"; > } > ?> > > thx sebastian > > Todd Ross schrieb: >> On 2/10/06, Sebastian Kurt <skurt-Mmb7MZpHnFY@public.gmane.org> wrote: >>> there are no '' in $rezept_vorgabe[$i]. i add the in the loop(PHP), see >>> for ($i=0;$i<$ende;$i++) { >>> echo "''".$region_vorgabe[$i]."''"; >>> } >> >> You are mistaken. >> >> ''Costa Rica'', >> ''Cote d''Ivoire'', >> ''Daenemark'' >> >> d''Ivoire needs to be escaped d\''Ivoire >> >> Todd >> >
On Friday 10 February 2006 15:05, Robin Haswell wrote:> Oh I see. How interesting. Eval scares me heh. Well in which case you''d > have to unit-test JSON vs XML to see which would be quicker. I have a > feeling it''d be close though, and I know which one I''d pick if that was > the case.no need to eval, he''s already printing this string into the page where he wants the javascript array to be, all the json module I was referring to would do would be to convert his array into the string he needs. Essentially, it would do what he''s already doing, but better. No need for any json parser or whatever in the browser. Take for example: <script type="text/javascript"> var myarray = [''bob'',''larry'',''frank'']; </script> or a php example: <script type="text/javascript"> var myarray = <?php some_json_converter(array("bob","larry","frank")); ?>; </script> the above two should produce the exact same code to the browser, aside from maybe differences in whitespace. -Jeremy -- Jeremy Kitchen ++ kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org In the beginning was The Word and The Word was Content-type: text/plain -- The Word of Bob. _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Oh I see! Sorry. That seems, well, bloody interesting. I don''t do anything like this at the moment (all AJAX) but I will consider that for the future. I do need a way to encapsulate a load of HTML inside a JS string accurately. At the moment''s I''m just doing search/replace escaping of quotes and newlines. Cheers -Rob Jeremy Kitchen wrote:> On Friday 10 February 2006 14:52, Robin Haswell wrote: > >> I think that''s a bit overkill. My fix should work fine for anything that >> doesn''t include newlines. If this were my application I''d dump the data >> in a hidden <ul><li> or maybe as an xml string and parse it with the >> built-in DOM parser. Much better parse something in XML than *shudder* >> javascript. JS shouldn''t be used for heavy data processing because it >> burdens the client (IMO). >> > > errr.... > > no, I meant for him to take his php array, let''s say it''s this: > $something = array ("bob", "larry", "frank"); > > then pass it to a JSON serializer, which will return a string, something like > this: > [''bob'', ''larry'', ''frank''] > > then drop that string in place where he currently has the broken javascript > array. The advantage is, he doesn''t have to think about the escaping of > strings and such, because the JSON serializer does it for him. > > I use this technique a lot in my own code for building an array/hash in perl > and then ''converting'' it to javascript and dropping it inside a <script> tag. > > -Jeremy > > -Jeremy > > > ------------------------------------------------------------------------ > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >
On Friday 10 February 2006 15:58, Robin Haswell wrote:> Oh I see! Sorry. That seems, well, bloody interesting. I don''t do > anything like this at the moment (all AJAX) but I will consider that for > the future. I do need a way to encapsulate a load of HTML inside a JS > string accurately. At the moment''s I''m just doing search/replace > escaping of quotes and newlines.yea, you could just find a JSON module for your programming language (I use perl''s JSON module, works great) and drop it in, voila. for here''s some perl code: #!/usr/bin/perl use strict; use JSON; my @array = ("how", "are", "you", "doing", "today"); print objToJson(\@array); this outputs: ["how","are","you","doing","today"] now if we make that array more complicated: my @array = qw( how''re "you" doing today? ''"q/3\\#\${]}[ ); that outputs: ["how''re","\"you\"","doing","today?","''\"q/3\\#\\${]}["] it automatically escapes everything for you. If you already have the object created in whatever language you want, just use some sort of JSON module to convert it to javascript for you. real easy :) -Jeremy -- Jeremy Kitchen ++ kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org In the beginning was The Word and The Word was Content-type: text/plain -- The Word of Bob. _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Nice. As I say, I don''t have a need to pass anything other than straight-up strings at the moment, but that certainly is worth remembering. Cheers. -Rob Jeremy Kitchen wrote:> On Friday 10 February 2006 15:58, Robin Haswell wrote: >> Oh I see! Sorry. That seems, well, bloody interesting. I don''t do >> anything like this at the moment (all AJAX) but I will consider that for >> the future. I do need a way to encapsulate a load of HTML inside a JS >> string accurately. At the moment''s I''m just doing search/replace >> escaping of quotes and newlines. > > yea, you could just find a JSON module for your programming language (I use > perl''s JSON module, works great) and drop it in, voila. > > for here''s some perl code: > > #!/usr/bin/perl > > use strict; > use JSON; > > my @array = ("how", "are", "you", "doing", "today"); > print objToJson(\@array); > > this outputs: > ["how","are","you","doing","today"] > > now if we make that array more complicated: > my @array = qw( how''re "you" doing today? ''"q/3\\#\${]}[ ); > that outputs: > ["how''re","\"you\"","doing","today?","''\"q/3\\#\\${]}["] > > it automatically escapes everything for you. If you already have the object > created in whatever language you want, just use some sort of JSON module to > convert it to javascript for you. real easy :) > > -Jeremy > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Robin Haswell wrote:> Michael Peters wrote: > >> >> Robin Haswell wrote: >> >>> Hm I may be mistaken. AFAIU JSON is a JS-compatible serialization form? >>> Do browsers have built-in JSON deserializers? >> >> >> Well, they''d have to if they have JS interpreters right? >> > > > Um no, I mean can you convert a JSON object into a memory construct > without parsing it with Javascript code. Hence, is there a built-in JSON > deserializer (that isn''t written in JavaScript).Isn''t that what eval() is?> As far as I am aware, > JSON isn''t part of the javascript language specification.Well, it''s not called JSON, but it is a part of the spec. eval( "{foo: 123, bar: 456}" ); As far as comparing it to XML - http://en.wikipedia.org/wiki/JSON#Comparison_to_XML_and_other_markup_languages -- Michael Peters Developer Plus Three, LP