客户端通过jquery serialize 提交表单数据
$("#submit_survey").click(function(){ $.post(SITE_URL+'activity/survey/savesurvey', {data:$('#survey_form').serialize()}, function(response){ if (response.error_code) { infotips(response.msg, $('.submit_tips')); } else { infotips('保存成功', $('.submit_tips'), 'right'); } }, 'json'); return false; });
在php端post到的数据为:
title=%E6%82%A8%E5%8F%AF%E4%BB%A5%E5%9C%A8%E8%BF%99%E9%87%8C%E5%88%9B%E5%BB%BA%E6%82%A8%E7%9A%84%E9%97%AE%E7%AD%94%E9%A2%98%E7%9B%AE%EF%BC%8C%E5%90%8C%E6%97%B6%E5%AF%B9%E9%97%AE%E7%AD%94%E6%B4%BB%E5%8A%A8%E5%8A%A0%E4%BB%A5%E8%AF%B4%E6%98%8E&cover_image=&file_name=&file_partpath=&description=&isgender=0&isarea=0&isage=0&question%5B1%5D=ghk&option%5B1%5D%5B0%5D=hgkhk&option%5B1%5D%5B1%5D=hkhj&option%5B1%5D%5B2%5D=khgkhk&option%5B1%5D%5B3%5D=&question%5B2%5D=hgkh&option%5B2%5D%5B0%5D=hkhjk&option%5B2%5D%5B1%5D=hjkhjl&option%5B2%5D%5B2%5D=
如何替换为正确的格式:
Array
(
[title] => dsgd
[cover_image] => hdsgdsg
[file_name] => 219_20130514170542.jpg
[file_partpath] =>
[description] =>
[isgender] => 0
[isarea] => 0
[isage] => 0
[question] => Array
(
[1] => dgdg
)
[option] => Array
(
[1] => Array
(
[0] => aa
[1] => bb
[2] => cc
)
)
)
回复讨论(解决方案)
不会吧?jq 这么弱智?!
按正常的标版提交处理就可以了
如果真的如你所说,那么 parse_str 就是为这准备的,当然你还需要先用 urldecode 解一下码
用$.post时不需要{data:$(form).serialize()}而是直接$(form).serialize()就行
也许因为这个,本来是分别独立的input值被变成了了data的string类型的值了啊
用$.post时不需要{data:$(form).serialize()}而是直接$(form).serialize()就行
也许因为这个,本来是分别独立的input值被变成了了data的string类型的值了啊
的确如此,多谢
不会吧?jq 这么弱智?!
按正常的标版提交处理就可以了
如果真的如你所说,那么 parse_str 就是为这准备的,当然你还需要先用 urldecode 解一下码
的确是我用错了
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn