title: How to execute jquery/javascript code inside a .html() of jquery
body: <p>Inside jQuery.html(), I want to execute the following script.</p>
  
  <pre><code>$("#row1").html("&lt;td id="cellId"&gt;&lt;script&gt;if (selectedStr) {var elem = $(\"#cellId\");       
  $(elem).bind(\"onRefresh\", function() {loadColor(selectedStr); storeStr(selectedStr);});$(elem).trigger(\"onRefresh\");) }&lt;/script&gt;&lt;td&gt;")
  </code></pre>
  
  <p>Requirement:</p>
  
  <p>I had a testPage.jsp which contains table with cells. When a particular cell is selected and "submit" button is clicked, a popup opens. In the popup page, some data is changed and is processed through ajax. The resultant ajax response has to be dynamically set to the parent row. The ajax response builds the whole content that is to be set.This is where I fail.
  The Ajax response will be something like this.
  <code>&lt;td&gt;.....&lt;td&gt;</code>
  <code>&lt;td&gt;.....&lt;td&gt;</code>
  <code>&lt;td&gt;content&lt;script&gt;...&lt;/script&gt;&lt;/td&gt;</code>
  <code>&lt;td&gt;.....&lt;td&gt;</code>
  <code>&lt;td&gt;content&lt;script&gt;...&lt;/script&gt;&lt;/td&gt;</code>
  ...
  Moreover the "selectedStr" is a javascript global variable in testPage.jsp.</p>
  
  <p>Problems:
  1. "selectedStr is undefined" is the browser error msg. I couldn't get reference to the global variable.
  2. The element binding is not happening.</p>
  
  <p>I tried to make use of jQuery.getScript(), jQuery.globalEval, jQuery.eval.
  I couldn't understand the {{html}} of JQuery.</p>
  
  <p>Thanks!</p>