PHP反序列化jQuery FORM帖子 [英] PHP unserialize jQuery FORM post

查看:106
本文介绍了PHP反序列化jQuery FORM帖子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<form action="index.php" method="POST" id="form">
<input type="text" name="guest" id="guest_name" class="textbox"/><br />
<textarea name="textarea" id="text" class="textarea"></textarea/><br />
<input type="submit" id="submit" class="submit"/><br />
</form>

jQuery

$.post("events.php?action=send", { data :  $("#form").serialize() }, function(data, error) { }

测试了发布数据中是否包含数据:

Tested if post DATA has the data in it:

echo var_dump($_POST['data']);

我明白了:

name=blabla&comment=blabla1

然后当我这样做

echo $_POST['guest'];

什么也没发生,这是 NULL.

问题:

我做错了什么?为何POST来宾不满?如果它在DATA中,并且表单的方法也是POST.

What have I done wrong? Why doesn't the POST guest get filled? if it's in DATA, and form's method is POST too.

谢谢!

推荐答案

将序列化的字符串作为数据参数传递给$ .post而不是其数据参数是序列化字符串的对象

Pass the serialized string as the data parameter to $.post not an object whose data parameter is the serialized string

$.post("events.php?action=send", $("#form").serialize() , function(data, error) { }

现在您将可以访问$_POST['guest']

这篇关于PHP反序列化jQuery FORM帖子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆