How can I parse this into an eval object with json2 dot js?
There is a url http: //blah.com/json.data that I want to call from a button like this
<input type="button" value"Go" onclick="go()" />
from the Go javascript function, I want to hit the blah url that simply has this type of data-content (it has no html) on the page:
userdetails.attribute.name=LastName
userdetails.attribute.value=Smith
userdetails.attribute.name=GivenName
userdetails.attribute.value=Michael
How can I use the eval() function to throw all of the data from that blah url into a var object1 so that I can do something like this:
document.getElementById("lname").innerHTML = object1.blah[1].LastName;
Thanks in advanced…I’m new to json2 but would like to start using it.
Use jQuery:
If your data is actually formatted as you posted in your example (which is not valid JSON), you may need to parse it by hand. You can tell jQuery to send you plain text instead of attempting to parse the response by setting the
dataTypesetting totext.