Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery append() data to a div by doing a .get() from a hyperlink
    primarykey
    data
    text
    <p>I want to achieve <a href="http://www.flipkart.com/search/a/books?query=php&amp;vertical=books&amp;dd=0&amp;autosuggest%5Bas%5D=off&amp;autosuggest%5Bas-submittype%5D=default-search&amp;autosuggest%5Bas-grouprank%5D=0&amp;autosuggest%5Bas-overallrank%5D=0&amp;Search=%C2%A0&amp;_r=_iN6OjEUPgVEgEvZj%2b%2bZmQ--&amp;_l=MHzwajeMCXBPHY1KaGPeZQ--&amp;ref=1a3d4e72-48d4-416e-b64f-c15ac08994ea&amp;selmitem=" rel="nofollow noreferrer">something like this</a>. Here the page automatically loads new content when I scroll down. I want to fetch the new set of data by clicking on a hyperlink at the bottom of my page.</p> <p>Being a newbie to AJAX, I was checking out <a href="https://stackoverflow.com/a/3999872/432720">this question</a> which is similar to mine, but it isn't working. All I get is an empty Object when I run the code. Here's the code in my files:</p> <p><strong>index.php</strong></p> <pre><code>&lt;a href="about.php"&gt;About Me&lt;/a&gt; &lt;br&gt; &lt;a href="contact.php"&gt;Contact Me&lt;/a&gt; &lt;div class="wrap"&gt;&lt;/div&gt; &lt;script&gt; (function(){ var wrap = $('div.wrap'); $('a').on('click', function(e){ var href = $(this).attr('href'); $.get(href, function(data){ console.log($(data).find('div.container')); $(data).find("div.container").appendTo(wrap); }); e.preventDefault(); }); })(); &lt;/script&gt; </code></pre> <p><strong>about.php</strong></p> <pre><code>&lt;/div&gt; &lt;div class="container"&gt; &lt;h2&gt;About Me&lt;/h2&gt; &lt;p&gt;I suck at AJAX ! :-(&lt;/p&gt; &lt;/div&gt; </code></pre> <p><strong>contact.php</strong></p> <pre><code>&lt;div class="container"&gt;&lt;h1&gt;Contact!&lt;/h1&gt; &lt;form action="#"&gt; &lt;textarea name="content" id="content" cols="30" rows="10"&gt;&lt;/textarea&gt; &lt;input type="url" name="url" id="url"&gt; &lt;p&gt;&lt;button type="submit"&gt;Save&lt;/button&gt;&lt;/p&gt; &lt;/form&gt; &lt;/div&gt; </code></pre> <p><strong>Screenshot:</strong></p> <p><img src="https://i.stack.imgur.com/XZBMT.png" alt="Screenshot of empty Object"></p> <p>Am I missing something? Does <code>.get()</code> work inside the callback function of <code>click()</code> event? But it works fine when I <code>.load()</code> it... Sorry for the big post but I'm totally at a loss here! :/ Please help me out?</p>
    singulars
    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.
    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