Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to insert iFrame/PHP with ajax?
    primarykey
    data
    text
    <p>I am trying to include a Facebook like button iFrame that has PHP in it:</p> <pre><code> &lt;iframe src="http://www.facebook.com/plugins/like.php?href=&lt;?php echo $row['id']; ?&gt;&amp;send=false&amp;layout=button_count" style="border: medium none; overflow: hidden; width: 115px; height: 21px;" allowtransparency="true" frameborder="0" scrolling="no"&gt;&lt;/iframe&gt; </code></pre> <p>when the site loads this, it displays as in a list:</p> <pre><code> &lt;ul class="recent-list"&gt; &lt;?php require("inc/connect.php"); $result = mysql_query("SELECT * FROM entries ORDER BY id DESC LIMIT 0, 20", $link); while($row = mysql_fetch_array($result)){ ?&gt; &lt;li id="qoute-&lt;?php echo $row['id']; ?&gt;" class="quote-wrap group"&gt; &lt;span&gt; &lt;iframe src="http://www.facebook.com/plugins/like.php?href=&lt;?php echo $row['id']; ?&gt;&amp;send=false&amp;layout=button_count" style="border: medium none; overflow: hidden; width: 115px; height: 21px;" allowtransparency="true" frameborder="0" scrolling="no"&gt;&lt;/iframe&gt; &lt;/span&gt; &lt;div class="quote"&gt; &lt;p&gt; &lt;?php echo htmlentities($row['quote']); ?&gt; &lt;/p&gt; &lt;/div&gt;&lt;!-- /.quote --&gt; &lt;/li&gt; &lt;?php } ?&gt; &lt;/ul&gt; </code></pre> <p>But when someone click a button that fetches more list-items, the iFrame should be included...</p> <pre><code>function getQuotes(start, limit) { //Clear the recent list element //$(".recent-list").html(""); var recent = $(".recent-list"); $(".recent-list li").animate({opacity: 0.1} , 800).hide(500); $.ajax({ url: "quotes.php?start=" + start + "&amp;limit=" + limit, success: function (data) { data = jQuery.parseJSON(data) console.log("success"); //Data should now be a javascript array of objects. for (i = 0; i &lt; data.length; i++) { var newElem = jQuery("&lt;li&gt;&lt;/li&gt;").attr('id', data[i].id).addClass('quote-wrap-group'); newElem.append("&lt;div class='quote'&gt;&lt;p&gt;" + data[i].quote + "&lt;/p&gt;&lt;/div&gt;"); $(".recent-list").append(newElem); } } }); } var currentIndex = 0; $("#more").click(function () { getQuotes(currentIndex, 20); currentIndex += 10; }); </code></pre> <p>When I try to include the iframe in the js above, nothing happens. No error, nothing is returned...</p> <p>quotes.php:</p> <pre><code>$start = $_GET['start']; $limit = $_GET['limit']; $sql = "SELECT * FROM entries ORDER BY id DESC LIMIT ".$start.", ".$limit; $result = mysql_query($sql, $link) or die("Error in query: ".mysql_error()); $data = array(); while($row = mysql_fetch_array($result)) { array_push($data, $row); } echo(json_encode($data)); </code></pre> <p>live version. Click "Get more". The quotes appear, but no like button.</p> <p><a href="http://kdevs.site40.net/#more" rel="nofollow">http://kdevs.site40.net/#more</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload