I need help with one ajax function
This is raw page setup. Page will contain table with links in this form
.... link - button1 - button2 link - button1 - button2 link - button1 - button2 ...
where button1 is for hiding of row, and button2 is for hiding + adds+1 value to that link in db. every link will have unique id that will go with button2, so it would be easy to target it. So , visitor would click on one of button in a row, row will hide, then he moves to another row....
DB setup:
id - link - .... - nmbOFlikes
My problem is that I dont know Ajax, and it is only solution to update db without need to refresh after every button click.
That page is not static, it is formated by another function that draws data from db This is simple html page version, so if anyone could help...
So this is javascript without function
$(document).ready(function(){
$("button.live").click(function(){
$(this).parents('tr').hide();
alert('Link is hidden');
});
$("button.add").click(function(){
$(this).parents('tr').hide();
alert('This link is dead');
$.post("update_db.php", { id: button_id, increment: true },
function(data) {
alert("Link incremented");
});
}); });
And this is table
<table width="500" border="0" cellspacing="0" cellpadding="3">
<tr>
<td><p>Link 1</p></td>
<td><button class="live">live</button></td>
<td><button class="add" id="1">add</button></td>
</tr>
<tr>
<td><p>Link 2</p></td>
<td><button class="live">live</button></td>
<td><button class="add" id="2">add</button></td>
</tr>
</table>