Hello! I have this question. There is a forum. There is a voting system through AJAX . But when you click on the "+" or "-" score does not change immediately, only through f5 . Can I do this without reloading the page? Here is the code:
$('button[id=up]').live.click(function(){ id=$(this).parent().attr('id'); pm=1; //означает, что надо будет прибавить 1 // p=$(this).parent().parent().$('p').text(); // alert(p); $.ajax({ url:"add.php", type:"POST", data: {id:id, pm:pm}, //beforesend: alert("1"), success: function(d){alert(d)} }); }); And here is index.php :
while($row=mysql_fetch_array($res)){ //row[0] eto id $t.="<span>$row[1] (id #<span id=$row[0]>$row[0]</span>)<div><form id=$row[0]><button id='up'>+</button><button id='down'>-</button></form><p>$r</p></div><br>$row[3]<hr /></span>"; $w++; } echo $t;