It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Why won't my JSON work?

Why won't my JSON work?

Postby nozavroni on Fri Mar 23, 2007 4:25 am

Is there something wrong with my ajax? For some reason, as soon as I try to eval() the response, javascript no longer works. There are no errors in my error console at all. What could be causing this??

request
Code: Select all
    new Ajax.Request('ajax.php',
    {
        asynchronous:true,
        method: 'post',
        postBody: 'action=load_block&block_select=' + show_name,
        onSuccess: function(transport)
        {
           alert('TEST1');  // this gets alerted
            var response = transport.responseText || null;
            alert(response); // shows the json below...
            var data = eval("(" + response + ")");
            alert('TEST2'); // this does not
        },
        onFailure: function()
        {
           alert('Something went wrong...');
        }
    });

response:
Code: Select all
{
    "0":[
        "name":"Apacalypto",
        "id":"8",
        "duration":"149"
    ],
    "1":[
        "name":"Apacalypto",
        "id":"9",
        "duration":"149"
    ],
    "2":[
        "name":"Alpha Dogg",
        "id":"10",
        "duration":"148"
    ],
    "3":[
        "name":"Alpha Dogg",
        "id":"11",
        "duration":"148"
    ],
    "4":[
        "name":"Alpha Dogg",
        "id":"12",
        "duration":"148"
    ]
}
nozavroni
 
Posts: 0
Joined: Fri Mar 23, 2007 4:22 am

Who is online

Users browsing this forum: No registered users and 6 guests