Note that there are some explanatory texts on larger screens.

plurals
  1. POLoad text from specific div in text file using ajax
    primarykey
    data
    text
    <p>I'm using the <a href="http://designwithpc.com/Plugins/Hovercard" rel="nofollow">jquery hovercard plugin</a> to pull in text from a text file using ajax when a user hovers over a particular text string - this all works great, (code below).</p> <p>Now what I would like to do is have a number of different divs inside the text file, (shown below), and pull in the relevant one depending on which text string is hovered over. Is this possible with Jquery/Ajax, and if yes, how do you do it please? </p> <p><em>//Text File Contents</em></p> <pre><code>&lt;div id="John_Resig"&gt; &lt;div class="contact"&gt;John Resig&lt;/div&gt; &lt;p&gt;&lt;strong&gt;Testing testing testing!&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;And on another line of text : )&lt;/p&gt; &lt;/div&gt; &lt;div id="Tim_Berners_Lee"&gt; &lt;div class="contact"&gt;Tim Berners-Lee&lt;/div&gt; &lt;p&gt;&lt;strong&gt;Testing testing testing!&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;And on another line of text : )&lt;/p&gt; &lt;/div&gt; </code></pre> <p><em>//Jquery/Ajax Code</em></p> <pre><code>$(document).ready(function () { var hoverHTMLDemoAjax = '&lt;div class="demo-cb-tweets"&gt;&lt;/div&gt;'; $(".demo-ajax").hovercard({ detailsHTML: hoverHTMLDemoAjax, width: 350, delay: 500, cardImgSrc: 'http://ejohn.org/files/short.sm.jpg', onHoverIn: function () { $.ajax({ url : "helloworld.txt", type: 'GET', dataType: "text", beforeSend: function () { $(".demo-cb-tweets").prepend('&lt;p class="loading-text"&gt;Loading latest tweets...&lt;/p&gt;'); }, success: function (data) { $(".demo-cb-tweets").empty(); $(".demo-cb-tweets").html(data); }, complete: function () { $('.loading-text').remove(); } }); } }); }); </code></pre>
    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