title: Script not working inside foreach, how to run it via ajax?
body: <p>I have been trying to make a script work after clicking a table. Pretty much, when you visit your favorite email provider, you click on a new email and it opens up, that is what I am aiming for. I haven't been able to run ckeditor after the click.</p>
  
  <h2>retrieve data and post to table</h2>
  
  <pre><code>$getInfo = $articleClass-&gt;get_all_article_info();
  
  foreach($getInfo as $data)
  {
      $article_title = $data['article_title'];
      $article_content = substr(htmlentities($data['article_content']),0,50).'...';
      $article_content_full = $data['article_content'];
  
      echo '
          &lt;tr id="tr_id"&gt;
              &lt;td class="marker"&gt;
                  &lt;i class="fa fa-align-left"&gt;&lt;/i&gt;
              &lt;/td&gt;
  
              &lt;td class="title"&gt;
                  '.$article_title.'
              &lt;/td&gt;
  
              &lt;td class="content"&gt;
                  '.$article_content.'
              &lt;/td&gt;
          &lt;/tr&gt;
  
          &lt;section id="post_info_id" style="display:none;"&gt;
  
              &lt;textarea id="editor1" name="editor1"&gt;&lt;/textarea&gt;
  
              &lt;script&gt;
                  CKEDITOR.replace( "editor1",
                  {
                      toolbar: "Basic",
                  });
  
                  CKEDITOR.instances.editor1.setData( "'.$article_content_full.'", function()
                  {
                      this.checkDirty();
                  });
              &lt;/script&gt;
  
          &lt;/section&gt;
      ';
  }
  </code></pre>
  
  <h2>clicking action on table</h2>
  
  <pre><code>$(document).ready(
  function()
  {
      $("#tr_id").click(function()
      {
          $("#post_info_id").css("display", "block");
          $("#table_id").hide();
      });
  });
  </code></pre>
  
  <h2>Issue</h2>
  
  <p>When I click on a row, it just opens the editor1 textarea, but not the script I am wanting to load. If I remove the first script I posted above that is inside the echo and put it on the footer of the .php file, the script loads just fine but I need it inside the foreach otherwise it will not work, how do I make it run on ajax? I have absolutely no experience with ajax, but willing to learn.</p>
  
  <h2>EDIT:</h2>
  
  <p>I cannot figure out how to make this piece of code inside ajax.</p>
  
  <pre><code>CKEDITOR.replace( "editor1",
  {
      toolbar: "Basic",
  });
  
  CKEDITOR.instances.editor1.setData( "'.$article_content_full.'", function()
  {
      this.checkDirty();
  });
  </code></pre>