views:

827

answers:

1

i have jquery global error event set, like following:

 $("#message_alert").ajaxError(function(event, XMLHttpRequest, settings, thrownError){
  ajax_error(XMLHttpRequest);
 });

and ajax_error method gets the XMLHttpRequest parameter totally fine init. now the request which XMLHttpRequest gets, it also have json data from the backend in XMLHttpRequest.responseText

now i want to know, how can i parse this json data, i tried doing

eval("var request = "+XMLHttpRequest.responseText);

which for some reason was working fine, but dose not work anymore and i know for sure that data is getting back to ajax response. maybe something im doing wrong.. well firebug shows following error from it, i dont know what im doing wrong

Error:

missing ; before statement
http://basit.io.im/javascript/global.js
Line 127

btw this is the same eval line number. any ideas?

A: 

Have you tried -

eval("var request = XMLHttpRequest.responseText");

That should fix the error you are getting.

Colin
thank you, but i think error is something else. not related javascript.. stupid me :(
Basit
really? even though the eval statement is on line 127 of global.js or did I misunderstand? If you have it live anywhere I can take look if you want?
Colin