title: How to correctly use returned array with Jquery (ajax)
body: <p>Php function :</p>
  
  <pre><code>public function getThreadsbyNumber($number) {
      $result = mysql_query("SELECT * FROM `threads` LIMIT $number");
      while ($fetch = mysql_fetch_array($result)) {
          $threads[] = $fetch;
      }
      return $threads;
  }
  </code></pre>
  
  <p>Ajax url file :</p>
  
  <pre><code>require_once '../Classes/MainController.php';
  $mc = MainController::getInstance();
  $result = $mc-&gt;getThreadsbyNumber(5);
  foreach ($result as $thread) {
  print json_encode($thread['url']);
  }
  </code></pre>
  
  <p>the print returns the following (which are valid video id's):</p>
  
  <pre><code>"UjN_aX84Qco""lB6K60mkmho""ReRcHdeUG9Y""aXD6prwrYGw""b6pvDKjp-_s"
  </code></pre>
  
  <p>Up until now everything is working great. This is the html in which the output of the jquery function will go :</p>
  
  <pre><code> &lt;div class="row"&gt;
          &lt;div class="large-3 small-6 columns"&gt;
              &lt;a class="th" id="small_th_1"&gt;&lt;img src="http://placehold.it/500x500&amp;text=LEL_Error"&gt;&lt;/a&gt;
              &lt;div class="panel"&gt;
                  &lt;p id="small_th_1_description"&gt;Description&lt;/p&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>I want to add between  here  an iframe based on the video id provided by the php file but I can't get the jquery function to work. This is the jquery function :</p>
  
  <pre><code>   function getThreadsbyNumber() {
      $.ajax({
      type: "post",
      url: "Ajax/getThreadsbyNumber.php",
      dataType: "json",
      success: function(data) {
          $('#mainHeadline').html('&lt;iframe width="320" height="240" src="//www.youtube.com/embed/'+data[0]+'?autoplay=1" frameborder="0""&gt;&lt;/iframe&gt;');
          $('#small_th_1').html('&lt;iframe width="320" height="240" src="//www.youtube.com/embed/'+data[1]+'?autoplay=1" frameborder="0""&gt;&lt;/iframe&gt;');
          $('#small_th_2').html('&lt;iframe width="320" height="240" src="//www.youtube.com/embed/'+data[2]+'?autoplay=1" frameborder="0""&gt;&lt;/iframe&gt;');
          $('#small_th_3').html('&lt;iframe width="320" height="240" src="//www.youtube.com/embed/'+data[3]+'?autoplay=1" frameborder="0""&gt;&lt;/iframe&gt;');
          $('#small_th_4').html('&lt;iframe width="320" height="240" src="//www.youtube.com/embed/'+data[4]+'?autoplay=1" frameborder="0""&gt;&lt;/iframe&gt;');
      }
  
      });
      }
  </code></pre>