sending AJAX post id for MySQL delete

sending AJAX post id for MySQL delete

Hi guys,
I am trying to do something simple in PHP but using jQuery AJAX. I don't know about Javascript, so take it easy on me!

I have made a deleteajax.php
  1. require_once('../Connections/conn.php'); //database connection
  2. if($_POST['id'])
  3. {
  4. $id=$_POST['id'];
  5. $id = mysql_escape_String($id);
  6. mysql_select_db($database_XXXX, $conn);
  7. $sql = "DELETE FROM students WHERE student_id ='$id'";
  8. mysql_query( $sql);
  9. }


and using this script on the main page
  1. <script type="text/javascript">
  2. $(function() {
  3. $(".delete_button").click(function() {
  4. var id = $(this).attr("id");
  5. document.write(id);
  6. var dataString = 'id='+ id ;
  7. var parent = $(this).parent();
  8. $.ajax({
  9. type: "POST",
  10. url: "deleteajax.php",
  11. data: dataString,
  12. cache: false,
  13. success: function()
  14. {
  15. if(id % 2)
  16. {
  17. parent.fadeOut('slow', function() {$(this).remove();});
  18. }
  19. else
  20. {
  21. parent.slideUp('slow', function() {$(this).remove();});
  22. }
  23. }
  24. });
  25. return false;
  26. });
  27. });
  28. </script>

and this link in the body to send the delete request
  1. <a href="#" id="510" class="delete_button">X</a>
What is wrong? It is not refreshing the page (good) but I can't track what is being posted.. tried HTTP live headers, nothing happens.
Any ideas?