I have this bit of code that I am using in a project which I got working on a test webpage, and then when I tried to implement it on the real webpage, it all works, except for the jQuery effects.
Here is the code:
$(function(){
$("a.vote_up").click(function(){
//get the id
the_id = $(this).attr('id');
// show the spinner
$(this).parent().html("<img src='../../images/spinner.gif'/>");
//fadeout the vote-count
$("span#votes_count"+the_id).fadeOut("fast");
//the main ajax request
$.ajax({
type: "POST",
data: "action=vote_up&id="+$(this).attr("id"),
url: "../../votes.php",
success: function(msg)
{
$("span#votes_count"+the_id).html(msg);
//fadein the vote count
$("span#votes_count"+the_id).fadeIn();
//remove the spinner
$("span#vote_buttons"+the_id).remove();
}
});
});
});
What I have are stories which are on the home page, and then when you click on a link, it mod_rewrites the URL to something along the lines of 'www.something.com/example/this-is-the-story-title/' and then on that page I have that javascript.
What the javascript does is sends the info to votes.php and then votes.php processes that data and submits it to the database and then returns either 'Successful' or 'Failed' at the end of the file.
On my test page, everything was working, but on the real page, the effects don't work (i.e. The graphic of the spinner keeps spinning, and the old text doesn't fade out and new text doesn't fade in.)
I think it may have something to do with the '../../votes.php' part, as in the test page, it was only 'votes.php' but I may be wrong.
Any idea's guys?
Cheers,
Colm