hi..
earlier i ws using xml for interchanging data between server and
browser. nw i want to use json.. jus to try out..i am converting xml
to json using xml2json parser.now i want to extract data from that and
put it in my html form. hw to extract information frm json. if i use
eval() then nothing is happening. i am putting my code here..
function showResponse(originalRequest)
{
var response = originalRequest.responseXML;
var myJsonObject=xml2json(response);
alert(myJsonObject); \\this is yielding result but nothing is
coming after that
var parsedJson = myJsonObject.evalJSON();
alert(parsedJson);
alert(parsedJson.item.info.id);
}
Please tell where i am wrong.
this is the json after converting it with xml2json parser.
{
item:{
info:{
id:''"+productId+"'',
name:''"+name+"'',
company:''"+company+"'',
cost:''"+cost+"'',
desc:''"+desc+"''
}
}
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Are you seeing real JSON data in that alert(parsedJson)?
Here''s what I did to debug this sort of thing (though I did have an
XML step) - throw in a textarea field on your page, give it an id
name, and dump the contents of a variable into it via $
(''textarea_id_name'').value = yourVar. I find that works better
than an
alert, as you can look at it later and scroll through it etc.
Do that, and if the contents appear to be JSON structured info, cut/
paste it here.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Hi Scott,
in alert i am getting the real JSON data...like the one below....
{
item:{
info:{
id:''"+productId+"'',
name:''"+name+"'',
company:''"+company+"'',
cost:''"+cost+"'',
desc:''"+desc+"''
}
}
but after eval and all i am not getting anything
var parsedJson = myJsonObject.evalJSON();
alert(parsedJson);
alert(parsedJson.item.info.id);
these 3 lines r not working . that is i cant extract data from it
On Apr 23, 7:53 pm, ScottW
<sweik...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Are you seeing real JSON data in that alert(parsedJson)?
>
> Here''s what I did to debug this sort of thing (though I did have
an
> XML step) - throw in a textarea field on your page, give it an id
> name, and dump the contents of a variable into it via $
> (''textarea_id_name'').value = yourVar. I find that works
better than an
> alert, as you can look at it later and scroll through it etc.
>
> Do that, and if the contents appear to be JSON structured info, cut/
> paste it here.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
hey can u tell me how to set header for json in servlet so that if i use evalJson(), it cn recognise it.. On Apr 23, 7:53 pm, ScottW <sweik...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Are you seeing real JSON data in that alert(parsedJson)? > > Here''s what I did to debug this sort of thing (though I did have an > XML step) - throw in a textarea field on your page, give it an id > name, and dump the contents of a variable into it via $ > (''textarea_id_name'').value = yourVar. I find that works better than an > alert, as you can look at it later and scroll through it etc. > > Do that, and if the contents appear to be JSON structured info, cut/ > paste it here.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---