ajax not working for LIKE Button

Lymnattam

New Member
I'm having some issues with AJAX/JS and PHP. What i'm trying to do is a LIKE button, when if clicked, the page is not reloaded, but the like column for a particular comment is updated. I have being able to come up with these two scripts php and AJAX. but as it is now nothing shows up on the screen when i load about_cs.php and click the LIKE Button.Please where could my problem be coming from?Thanks for your time and patience, I most appreciate it.Thank you.about_cs.php\[code\] $q = "SELECT c.comment_id FROM comment AS c INNER JOIN about AS ac ON c.article_id = ac.about_id WHERE c.article_id = '".$article_id."' AND page_name = '".$page_name."'" or die (mysql_error()); $r = mysql_query($q); if(mysql_num_rows($r)==1) { $row = mysql_fetch_assoc($r); $likes = $row['votes_up']; } $comment_id = $_GET['comment_id']; $action = $_GET['action']; if($action=='like') { $total_likes = $likes+1; $q = "UPDATE comment SET like = $total_likes WHERE c.article_id = '".$article_id."' AND page_name = '".$page_name."'"; }\[/code\]LIKE Button\[code\]echo "<a class=\"like\" href=http://stackoverflow.com/questions/10559339//"about_cs. php?action=like&comment_id= $comment[comment_id]&article_id=$_ SESSION[article_id] \"><img src =http://stackoverflow.com/questions/10559339//"like. jpeg\" ></a>"; $(function(){ $(".like").click(function(){ the_id = $(this).attr('comment_id'); $.ajax({ type: "GET", data: "action=likep&comment_id ="+$(this).attr("comment_id"), url: "about_cs.php", success: function(msg) { $("span.likes"+the_id).html(msg); } }); }); });\[/code\]
 
Back
Top