Question

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?

Was it helpful?

Solution

Have you tried -

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

That should fix the error you are getting.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top