Board index   FAQ   Search  
Register  Login
Board index php forum :: HTML JavaScript

like button isn't working

Javascript coding ..

Moderators: macek, egami, gesf

like button isn't working

Postby suchait24 » Sat Feb 09, 2013 8:57 am

Hi frds

I created a like button



What i need : when user click on this button,it must be disabled

my problem: code isn't working....

<script type="text/javascript">


$(function() {

$('.like').live("click",function()
{
var ID = $(this).attr("id");
var dataString = 'msg_id='+ ID; //passing id of msg



$.ajax({
type: "POST",
url: "count_like.php", //php script which contains the backend working .
data: dataString,
cache: false,
success: afterSuccess //call function after success


});




return false;
});




});

function afterSuccess() { //this part of function isn't working

$("#like").attr("disabled","disabled");
$("#like").css("background-color","silver");


$("#like").click(function(e){
if($("#like").attr("disabled")=="disabled")
{
e.preventDefault();
}
});


}



</script>



In this code ajax calling is working fully fine as i need but disabling function isn't working...

help please
Thnx in advance
suchait24
New php-forum User
New php-forum User
 
Posts: 3
Joined: Thu Jan 24, 2013 4:50 am

Re: like button isn't working

Postby seandisanti » Wed Mar 06, 2013 3:22 pm

in the working section, your selector is grabbing elements with the 'like' class, in the other section your selector is for the 'like' id. Without seeing your html for the button, I would assume that the one not working is using the wrong selector.
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm


Return to JavaScript

Who is online

Users browsing this forum: No registered users and 0 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.