我的一个php页面已更改为处理POST
数据(为了容纳一些表单文本字段),而不是GET
(以前使用过)。
现在,它使用if($_GET) { }
代替if($_POST) { }
。他们(团队)不会允许使用||
两种方法。
我需要使用jQuery向同一页面发送查询字符串,但由于if($_POST) { }
,它无法通过。
查询字符串由此形成:<i class="icon-hand remove" data-handle="se25p37x"></i>
我以前使用jQuery ajax发送它,但现在不行。知道怎么把它作为POST发送吗?
$('.remove').live('click', function() {
var self = $(this);
var handle = $(this).data("handle");
if(handle) {
$.ajax({
type:"POST", // this used to be GET, before the change
url:"/user/actions/"+handle,
dataType:'json',
beforeSend:function(html) {
},
答案 0 :(得分:1)
只需将type: "GET"
更改为type: "POST"
并添加data
参数:
...
type: "POST",
data: $('form').serialize(), // OR data: {handle: $(this).data("handle")}
dataType: 'json',
...