Heim > Artikel > Backend-Entwicklung > post数据的问题
我用浏览器自带的调试工具截获的传输数据是这样的:
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
$.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"); },
$.ajax('/index.php/game/postCode' 这个能成功提交到php里吗
$.ajax('/index.php/game/postCode' 这个能成功提交到php里吗
你在php脚本里,返回json格式数据时,用json_encode($arr)处理下
你在php脚本里,返回json格式数据时,用json_encode($arr)处理下
post提交的数据会被用urlencode处理。自己模拟那用curl模拟post提交吧
urlencode:
返回字符串,此字符串中除了 -_. 之外的所有非字母数字字符都将被替换成百分号(%)后跟两位十六进制数,空格则编码为加号(+)。此编码与 WWW 表单 POST 数据的编码方式是一样的,同时与 application/x-www-form-urlencoded 的媒体类型编码方式一样
post提交的数据会被用urlencode处理。自己模拟那用curl模拟post提交吧
urlencode:
返回字符串,此字符串中除了 -_. 之外的所有非字母数字字符都将被替换成百分号(%)后跟两位十六进制数,空格则编码为加号(+)。此编码与 WWW 表单 POST 数据的编码方式是一样的,同时与 application/x-www-form-urlencoded 的媒体类型编码方式一样