Using Ajax To POST Something

Using Ajax To POST Something

hi , this is my first time to asking a question in this website .
i have an ajax post method Like the below code 
$.ajax({type:"POST",url:"functions.php",data:{"Showdata":"showdatatouser"},success:function(data){
$('#datagridview').html(data);
}});

as you can see im just posting somthing to functions.php

into the functions.php we have couple lines of code , that's return for me a Table content with couple Links in the top of that Table .

after that i just defined an event  for that links at the top of the table and it work like this

$('#Links').click(function(){
alert('yes');
});

i dont know why this event dosnt work fine . but when i put it into the success function of that ajax it w'll works fine . i dont know what's the reason for that ?
the below code w'll works fine at last , but i dont know what's the reason ...

$.ajax({type:"POST",url:"functions.php",data:{"Showdata":"showdatatouser"},success:function(data){
$('#datagridview').html(data);

                  $('#Links').click(function(){
alert('yes');
});

}});

i hope you get what i mean .