tags:

views:

293

answers:

1

I never had such a problem and I'm pretty puzzled:

function delete_post(id) {
  var answer = confirm("Are you sure you want to delete your post? (this action cannot be undone)")

  if (answer) {
    $.ajax({ 
      method:"post",
      url: "ajax/delete.php",
      data:"id="+id,
      beforeSend: function(){ $('#delete_post').show('slow'); },
      success: function(html) { $("#delete_post").html(html); }
    });
  }
  else {}
  return false;
}

I had a problem on the server side and, after analizing the output with firebug I noticed that the request turns out to be a GET instead of a post! What Am I missing here?

+2  A: 

Oh easy one. The property is type not method:

$.ajax({ 
  type:"POST",
  url: "ajax/delete.php",
  data:"id="+id,
  beforeSend: function() {
    $('#delete_post').show('slow');
  },
  success: function(html) {
    $("#delete_post").html(html);
  }
});

Note: from the documentation the method (type) is in uppercase ('GET', 'POST'). I don't actually know if it matters or not however.

cletus
D'oh, I thought it was method and not type.. thank you!
0plus1