var returns undefined. You should wrap json in parenthesis, then evaluate it:

eval('('+json+')')

brito

On 9/18/06, Sam Sherlock < [EMAIL PROTECTED]> wrote:
Ealier Klaus recommended usig JSON to process an object

here is the code I am using

$.ajax({
    url: "./content/?" + htmlDoc,
    dataType: 'json',
    success: function(json) {
        // process json...

                        eval("var myVar = " + json +";"); // this line is causing an error. (see below)

                       
                        console.info('    title0: ' + myVar.item[0].title);


    },
    error: function() {
    }
})

my object looks like this:
{'title':'credits', 'content':'    <div id="credits"><h2>Credits</h2>
<div><p>Content</p></div></div>', 'image':'<img src="" width="467" height="750" alt="" />', 'music':8}

also should I have quotes around the prop name aswell as the value of the prop? some example do and some don't maybe this is optional?

the error caused by the eval is
                    missing ] after element list http://ss29/... (line 104)
                    var myVar = [object XMLHttpRequest];

what I am doing wrong?



_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/



_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to