Hi,
I''m just getting into this and can''t seem to get the
evalJSON() to
work.
I''m using the stuff exactly out of the api docs.
<script>
new Ajax.Request(''ClientStatusData.jsp'', {
method:''get'',
onSuccess: function(transport){
json = ''{ "name": "Violet",
"occupation":
"character" }''.evalJSON();
alert(json ? json.name : "no JSON object");
}
});
</script>
I just get nothing.
What stupid mistake am I doing?
Prototype 1.5 and Firefox.
thanks for any pointers.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
oanderson wrote:> Hi, > > I''m just getting into this and can''t seem to get the evalJSON() to > work. > > I''m using the stuff exactly out of the api docs. > > <script> > > new Ajax.Request(''ClientStatusData.jsp'', { method:''get'', > onSuccess: function(transport){ > json = ''{ "name": "Violet", "occupation": > "character" }''.evalJSON();Why even use a JSON string? Just use a literal: json = { "name": "Violet", "occupation": "character" }; -- Michael Peters Developer Plus Three, LP --~--~---------~--~----~------------~-------~--~----~ 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 was also having same problem then I used the regular javascript eval
function to create an object out of string content
json = ''{ "name": "Violet",
"occupation": "character" }''
eval("("+json +")")
On May 22, 9:20 pm, oanderson
<oander...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi,
>
> I''m just getting into this and can''t seem to get the
evalJSON() to
> work.
>
> I''m using the stuff exactly out of the api docs.
>
> <script>
>
> new Ajax.Request(''ClientStatusData.jsp'', {
method:''get'',
> onSuccess: function(transport){
> json = ''{ "name": "Violet",
"occupation":
> "character" }''.evalJSON();
>
> alert(json ? json.name : "no JSON object");
>
> }
> });
> </script>
>
> I just get nothing.
>
> What stupid mistake am I doing?
>
> Prototype 1.5 and Firefox.
>
> thanks for any pointers.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---