what's wrong with this JSON
Posted: Thu Mar 22, 2007 10:02 pm
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
response:
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...');
}
});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"
]
}