help with passing variable to ajax

help with passing variable to ajax

  1. <script>
  2. $(document).ready(function(){

  3. $('td img').click(function(){
  4. alert($(this).attr('id'));
  5. });
  6. $.ajax({
  7.     type: "POST",
  8.     url: "some.php",
  9.     data: "id=" + id,
  10.     success: function(data){
  11.      alert( "Data" );
  12.  
  13.    }
  14.  });
  15. });
  16. </script>

  17. I am new to jquery and I was wondering on how to send the id of the image I clicked on to a ajax call.