It works first time but there is just a small problem in that it’s not pulling the correct data across. I’ll just run through what I did, as I understood it.
I set up a separate template called ‘archive’ with just the entries that I need for the data to be inserted on hover. I set the template up to allow PHP and then set the template to parse php on input so it reads the top variable first before it deals with the EE tags.
<?php
$id = $_POST['id'];
?>
{exp:channel:entries channel="blog" limit="1" entry_id="<?php echo $id; ?>"}
<span>{entry_date format="%j %M %Y"}</span>
<h1><a href="http://{title_permalink}">{title}</a></h1>
<div id="livePostInner">
{exp:antenna url='{video}' max_width="400" max_height="170"}
{exp:imgsizer:size src="{image}" width="400" height="170"}
{sized}
{/exp:imgsizer:size}
</div>
"{intro}"
<a href="http://{title_permalink}class=readMore">read more</a>
<div id="feedback">
<ul>
<li class="comments"><a href="#"> 5 Comments</a></li>
<li class="twitter"><a href="#">Share On Twitter</a></li>
<li class="facebook"><a href="#">Share On Facebook</a></li>
</ul>
</div>
{/exp:channel:entries}
I then set up a rel tag for the link in the archive list, this sets the relationship between the current document and the linked document, in this case the entry ID.
<ul id="archive">
{exp:channel:entries channel="blog"}
<li><a href="http://{title_permalink}rel={entry_id}">{short_title} / {entry_date format="%Y"}</a></li>
{/exp:channel:entries}
</ul>
I then, on my index page, set the jQuery. So on hover it get’s the data from the rel tag and assigns that to a variable called entryID. It then initiates the ajax by sending over the entryID to the template and if successful replaces the html in the #livePost div.
<pre><code>$(’#archive a’).mouseenter(function(){
var entryID = $(this).attr('rel');
$.ajax({
type: "POST",
url: "http://site.com/index.php/archive",
data: "id="+entryID,
success: function(data){
$('#livePost').html(data);
}
});
});</code></pre>
When I check the Console in Firebug, the post data says it’s pulling the right source ‘Source id=1”, so that is correct, it should be getting the post with the entry=1 as the current index page is displaying the latest blog, entry ID 2. However when I check the response, it lists all the right data fields it’s bringing across, but it just seems to bring across the current blog information (entry=2). I changed some of the static HTML to check that something was actually happening, I changed the comment count in the archive template to a different number and that changes on hover so it is pulling the data across, it just seems to be pulling in the wrong entry data even though it says it’s bringing in the right entry ID.
Any ideas as to where it could be going wrong?
Thanks for the help so far!