How can I execute Javascript via ExtJS AJAX call without eval() as I can with JQuery? -
i execute javascript in pages load via ext.ajax.request
. this, have load scripts , eval()
them this:
ext.ajax.request({ url: 'content/view_application.php', success: function(objserverresponse) { var responsetext = objserverresponse.responsetext; regioncontent.update(responsetext); var scripts, scriptsfinder=/<script[^>]*>([\s\s]+)<\/script>/gi; while(scripts=scriptsfinder.exec(responsetext)) { eval(scripts[1]); } } });
with jquery, however, can have javascript executed in pages called via ajax without resorting eval()
this:
function replacecontentonclick(id, pagetoload) { $('body').delegate(('#' + id), 'click', function(){ $.get('content/' + pagetoload, function(data) { $('#regioncontent .x-panel-body').html(data); }); }); }
how jquery manages execute javascript in loaded page without eval()
? there way load javascript without resorting eval()
in extjs well?
personally, wouldn't worry eval
statement. aware douglas crockford counsels against use:
eval evil
the eval function (and relatives, function, settimeout, , setinterval) provide access javascript compiler. necessary, in cases indicates presence of extremely bad coding. eval function misused feature of javascript.
(from http://www.jslint.com/lint.html)
here states "this necessary", , argue use valid one.
the json2.js library (http://www.json.org) uses command, , flags jslint intended:
/*jslint evil: true */
is there particular reason avoid use?
Comments
Post a Comment