jQuery-POST请求原来是GET请求..怎么来的?

我从来没有遇到过这样的问题,我很困惑:

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;
}

我在服务器端遇到了问题,在使用Firebug对输出进行分析之后,我注意到该请求原来是GET而不是帖子!我在这里想念什么?

最佳答案
哦,容易的一个.该属性是类型而不是方法:

$.ajax({ 
  type:"POST",beforeSend: function() {
    $('#delete_post').show('slow');
  },success: function(html) {
    $("#delete_post").html(html);
  }
});

注意:从documentation开始,方法(类型)为大写(“ GET”,“ POST”).我实际上不知道这是否重要.

相关文章

1.第一步 设置响应头 header('Access-Control-Allow...
$.inArray()方法介绍 $.inArray()函数用于在数组中搜索指定的...
jquery.serializejson.min.js的妙用 关于这个jquery.seriali...
JS 将form表单数据快速转化为object对象(json对象) jaymou...
jQuery插件之jquery.spinner数字智能增减插件 参考地址:http...