post数据的问题

WBOY
Release: 2016-06-23 13:25:59
Original
973 people have browsed it

我用浏览器自带的调试工具截获的传输数据是这样的:

Remote Address:110.173.51.13:80Request URL:http://1.cp556677.com/index.php/game/postCodeRequest Method:POSTStatus Code:200 OKRequest Headersview sourceAccept:application/json, text/javascript, */*; q=0.01Accept-Encoding:gzip,deflateAccept-Language:zh-CN,zh;q=0.8Connection:keep-aliveContent-Length:416Content-Type:application/x-www-form-urlencoded; charset=UTF-8Cookie:safedog-flow-item=79F5EE718A; mode=0.02; PHPSESSID=geoneh9vdsg9nlo21251iho006; fanDian=0Host:1.cp556677.comOrigin:http://1.cp556677.comReferer:http://1.cp556677.com/index.phpUser-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36 SE 2.X MetaSr 1.0X-Requested-With:XMLHttpRequestForm Dataview sourceview URL encodedcode[0][fanDian]:0code[0][bonusProp]:19.40code[0][mode]:0.02code[0][beiShu]:1code[0][orderId]:105178437687code[0][actionData]:-,-,01234,-,-code[0][actionNum]:5code[0][weiShu]:0code[0][playedGroup]:6code[0][playedId]:37code[0][type]:1para[type]:1para[actionNo]:20150924-026para[kjTime]:1443061200Response Headersview sourceCache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0Connection:Keep-AliveContent-Length:26Content-Type:application/jsonDate:Thu, 24 Sep 2015 02:13:05 GMTExpires:Thu, 19 Nov 1981 08:52:00 GMTKeep-Alive:timeout=5, max=95Pragma:no-cacheServer:Apache/2.4.7 (Win32) OpenSSL/0.9.8y PHP/5.3.28X-Powered-By:PHP/5.3.28
Copy after login


我自己提交的时候不是提示500错误,就是返回空,数据哪里应该是json数据,不知道json数据应该怎么返回,网站是用jQuery提交的,提交的相关代码是这样的:

$.ajax('/index.php/game/postCode', {				data:{					code:code,					para:data,					zhuiHao:zhuiHao				},				type:'post',				dataType:'json',				error:function(xhr, textStatus, errorThrown){					gamePostedCode(errorThrown||textStatus);				},				success:function(data, textStatus, xhr){					gamePostedCode(null, data);					if(data) winjinAlert(data,"ok");				},
Copy after login


我应该怎么样用程序模拟这个提交的过程,是不是提交json,有不一样的格式?


回复讨论(解决方案)

$.ajax('/index.php/game/postCode'  这个能成功提交到php里吗

$.ajax('/index.php/game/postCode'  这个能成功提交到php里吗



你在php脚本里,返回json格式数据时,用json_encode($arr)处理下

你在php脚本里,返回json格式数据时,用json_encode($arr)处理下



我是想知道这些参数是怎么传送过去的,如果变成网址是什么样的,如果自己模拟,应该是怎么模拟?不用ajax怎么模拟发送?

post提交的数据会被用urlencode处理。自己模拟那用curl模拟post提交吧
urlencode:
返回字符串,此字符串中除了 -_. 之外的所有非字母数字字符都将被替换成百分号(%)后跟两位十六进制数,空格则编码为加号(+)。此编码与 WWW 表单 POST 数据的编码方式是一样的,同时与 application/x-www-form-urlencoded 的媒体类型编码方式一样

post提交的数据会被用urlencode处理。自己模拟那用curl模拟post提交吧
urlencode:
返回字符串,此字符串中除了 -_. 之外的所有非字母数字字符都将被替换成百分号(%)后跟两位十六进制数,空格则编码为加号(+)。此编码与 WWW 表单 POST 数据的编码方式是一样的,同时与 application/x-www-form-urlencoded 的媒体类型编码方式一样



我就是研究不出来才到这里发帖问的
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!