Dean440
02-12-2010, 04:02 PM
Here is the exact string returned as responseText to my XHR Object:
{title:"Hello from the database!", keywords:"hello", description:"A brand new website!", body:"<h1>Website</h1>
<p>Hello from the database!</p>
"}
I've tried using this with no success:
var PageInfo = eval("(" + http.responseText + ")");
alert(PageInfo.title); //Does not alert anything
I've also tried putting "myVar = " at the beginning of the responseText and using just eval(http.responseText) to no avail. Lastly, I've tried this JSON.parse() method I saw somewhere, which didn't work.
So how's this properly done?
{title:"Hello from the database!", keywords:"hello", description:"A brand new website!", body:"<h1>Website</h1>
<p>Hello from the database!</p>
"}
I've tried using this with no success:
var PageInfo = eval("(" + http.responseText + ")");
alert(PageInfo.title); //Does not alert anything
I've also tried putting "myVar = " at the beginning of the responseText and using just eval(http.responseText) to no avail. Lastly, I've tried this JSON.parse() method I saw somewhere, which didn't work.
So how's this properly done?