This project is archived and is in readonly mode.

#868 ✓invalid

Request and usage of evalScripts with DOM related scripts

Reported by AHHP | March 15th, 2010 @ 02:35 PM


While using Request Class and set evalScripts to true, script tags will be executed and removed before sending response to OnSuccess event when response is string.
Please review sample below:

HTML Response:

<div id="myDiv">Some data</div>
<script type="text/javascript">'myDiv').setStyle('color', 'red');
The codes won't work because there is no "myDiv" when script is run.
I solved it for my probem as below but i'm looking for a official and better solution:
 success: function(text, xml){
  //this.onSuccess(this.processScripts(text), xml);
  this.onSuccess(text, xml);
 processScripts: function() {
  var scripts = this.getElements('script');
  scripts.each(function(script) {
   $exec( script.get('html') );
  return this;
new Request({
 onSuccess: function(response) {'someWhere').set('html', response).processScripts();


Comments and changes to this ticket

  • fakedarren

    fakedarren March 17th, 2010 @ 01:37 PM

    • State changed from “new” to “invalid”

    Hi AHHP,

    If you use the Request.HTML class, once the scripts have been stripped, they are stored in the response property, and you can $exec them. Or, you get passed the javascript as the fourth argument of the onSuccess method and again you can $exec them.

    Check the docs for Request.HTML as the onSuccess arguments are different from regular Request.

    Also, it's best to ask these kinds of questions in our Google Group or IRC channel as you'll get a much quicker response.


Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket