Heim  >  Artikel  >  php教程  >  post数据的有关问题

post数据的有关问题

WBOY
WBOYOriginal
2016-06-06 19:41:261396Durchsuche

post数据的问题 本帖最后由 ljaahh 于 2015-09-24 10:42:59 编辑 我用浏览器自带的调试工具截获的传输数据是这样的: RemoteAddress:110.173.51.13:80 RequestURL:http://1.cp556677.com/index.php/game/postCode RequestMethod:POST StatusCode:200OK Reques

post数据的问题

本帖最后由 ljaahh 于 2015-09-24 10:42:59 编辑

我用浏览器自带的调试工具截获的传输数据是这样的:
Remote Address:110.173.51.13:80<br />
Request URL:http://1.cp556677.com/index.php/game/postCode<br />
Request Method:POST<br />
Status Code:200 OK<br />
Request Headersview source<br />
Accept:application/json, text/javascript, */*; q=0.01<br />
Accept-Encoding:gzip,deflate<br />
Accept-Language:zh-CN,zh;q=0.8<br />
Connection:keep-alive<br />
Content-Length:416<br />
Content-Type:application/x-www-form-urlencoded; charset=UTF-8<br />
Cookie:safedog-flow-item=79F5EE718A; mode=0.02; PHPSESSID=geoneh9vdsg9nlo21251iho006; fanDian=0<br />
Host:1.cp556677.com<br />
Origin:http://1.cp556677.com<br />
Referer:http://1.cp556677.com/index.php<br />
User-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.0<br />
X-Requested-With:XMLHttpRequest<br />
Form Dataview sourceview URL encoded<br />
code[0][fanDian]:0<br />
code[0][bonusProp]:19.40<br />
code[0][mode]:0.02<br />
code[0][beiShu]:1<br />
code[0][orderId]:105178437687<br />
code[0][actionData]:-,-,01234,-,-<br />
code[0][actionNum]:5<br />
code[0][weiShu]:0<br />
code[0][playedGroup]:6<br />
code[0][playedId]:37<br />
code[0][type]:1<br />
para[type]:1<br />
para[actionNo]:20150924-026<br />
para[kjTime]:1443061200<br />
Response Headersview source<br />
Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0<br />
Connection:Keep-Alive<br />
Content-Length:26<br />
Content-Type:application/json<br />
Date:Thu, 24 Sep 2015 02:13:05 GMT<br />
Expires:Thu, 19 Nov 1981 08:52:00 GMT<br />
Keep-Alive:timeout=5, max=95<br />
Pragma:no-cache<br />
Server:Apache/2.4.7 (Win32) OpenSSL/0.9.8y PHP/5.3.28<br />
X-Powered-By:PHP/5.3.28


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

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


我应该怎么样用程序模拟这个提交的过程,是不是提交json,有不一样的格式?
【本文来自鸿网互联 (http://www.68idc.cn)】

------解决思路----------------------
$.ajax('/index.php/game/postCode'  这个能成功提交到php里吗
------解决思路----------------------
你在php脚本里,返回json格式数据时,用json_encode($arr)处理下
------解决思路----------------------
post提交的数据会被用urlencode处理。自己模拟那用curl模拟post提交吧
urlencode:
返回字符串,此字符串中除了 -_. 之外的所有非字母数字字符都将被替换成百分号(%)后跟两位十六进制数,空格则编码为加号(+)。此编码与 WWW 表单 POST 数据的编码方式是一样的,同时与 application/x-www-form-urlencoded 的媒体类型编码方式一样
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn