function vote(linkid,votes) { var url='/ajax/vote.js'; var params={ 'linkid': linkid, 'votes': votes }; var ajax=jQuery.ajax( { type: 'post', url: url, data: params, success: function(response) { eval("voteres= {"+response+"}"); var votediv=$('#voteimg-'+linkid); if (voteres.status == 1) { if (votediv) { votediv.innerHTML='Já tinha votado no link'; votediv.removeClass('votednok'); votediv.addClass('votedok'); } var uservotes=$('#uservotes'); uservotes.innerHTML=voteres.lastvotes; } else { if (votediv) { var vhtml = ' Vote contra 3 ponto Vote contra 2 ponto Vote contra 1 ponto Vote a favor 1 ponto Vote a favor 2 ponto Vote a favor 3 ponto '; vhtml.replace(/#{id}/g, linkid); votediv.innerHTML=vhtml; votediv.removeClass('votedok'); votediv.addClass('votednok'); } alert(voteres.errormsg); } }, error: function() { var votediv=$('#voteimg-'+linkid); if (votediv) { var vhtml = ' Vote contra 3 ponto Vote contra 2 ponto Vote contra 1 ponto Vote a favor 1 ponto Vote a favor 2 ponto Vote a favor 3 ponto '; vhtml.replace(/#{id}/g, linkid); votediv.innerHTML=vhtml; votediv.removeClass('votedok'); votediv.addClass('votednok'); } alert("Não foi possível enviar o seu voto."); }, beforeSend: function() { var votediv=$('#voteimg-'+linkid); if (votediv) { votediv.innerHTML=""; } }, } ); }