使用$('#form').serialize(),我能够将其发送到PHP 页面.现在我如何在 PHP 中反序列化它?它是在 jQuery 中序列化的.
Using $('#form').serialize(), I was able to send this over to a PHP page. Now how do I unserialize it in PHP? It was serialized in jQuery.
您不必通过 jquery serialize 方法对 PHP 中的任何内容进行反序列化.如果您序列化数据,如果您使用 GET 方法 ajax 请求,则应将其作为查询参数发送到 PHP,如果您使用 POST ajax 请求,则应将其作为查询参数发送到 PHP.因此,在 PHP 中,您将根据请求类型访问诸如 $_POST["varname"] 或 $_GET["varname"] 之类的值.
You shouldn't have to unserialize anything in PHP from the jquery serialize method. If you serialize the data, it should be sent to PHP as query parameters if you are using a GET method ajax request or post vars if you are using a POST ajax request. So in PHP, you would access values like $_POST["varname"] or $_GET["varname"] depending on the request type.
serialize 方法只是获取表单元素并将它们放在字符串形式中."varname=val&var2=val2"
The serialize method just takes the form elements and puts them in string form. "varname=val&var2=val2"
这篇关于我如何对 jQuery 序列化的表单进行 PHP 反序列化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
不能使用 'Object 作为类名,因为它是保留的Cannot use #39;Object as class name as it is reserved Cake 2.2.x(不能使用 Object 作为类名,因为它是保留的 Cake 2.2.x)
OAuth 重定向后会话丢失Session is lost after an OAuth redirect(OAuth 重定向后会话丢失)
Cakephp 3.x 中的分页排序Pagination Sort in Cakephp 3.x(Cakephp 3.x 中的分页排序)
CakePHP 多个应用程序的共享核心CakePHP Shared core for multiple apps(CakePHP 多个应用程序的共享核心)
在 CakePHP 3 上登录 [ Auth->identify() ] 始终为 falLogin [ Auth-gt;identify() ] always false on CakePHP 3(在 CakePHP 3 上登录 [ Auth-identify() ] 始终为 false)
致命错误:允许的内存大小为 134217728 字节已用尽Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 87 bytes)(致命错误:允许的内存大小为 134217728 字节已用尽