Dear All...

I'am new to jquery....
I have some problem. I have some link that have Id that auto generated
from mysql query, till now I could not figure out how jQuery know what
ID that i have clicked . For example:

// The FORM
$query = mysql_query("SELECT id,title FROM book ORDER BY id DESC");
<div id='result'></div>
<div id='operation'/>
while $fetch = mysql_fetch_array($query); {
     $id       = $fetch ['id'];
     $title    = $fetch ['id'];
     echo "$title
              | <a id='link_del$id'  href = "process.php?do=dell&id=
$id' /> <img id='img_del$id' scr='images/delete_icon.gif'/> </a>
             | <a id='link_edit$id' href = "process.php?do=edit&id=
$id' /> <img id='img_edit$id' scr='images/edit_icon.gif'/> </a>
    ";
}
</div>

In jquery I try to do this, but fail

// jQuery
$(document).ready(function(){

        ('.operation a').click(function(){
               $.ajax({
                        type: 'GET',
                        url: $(this).attr('href'),
                        data: $(this).serialize(),
                        success: function(data) {
                                $('#result').html(data);
                        }
                });
                return false;
        });

});

// PHP Process.php
$id=$_GET['id'];
$delete = mysql_query ("DELETE FROM book WHERE id='$id'");
if ($delete) { echo "YES"; }
else {echo "FAIL";}

any advice would be appreciated
Thank You...

Reply via email to