Post data problems

Source: Internet
Author: User
The problem of post data is that I use the debugging tool provided by the browser to intercept the data transmitted as follows:
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


When I submit it myself, I do not prompt 500 error, or return NULL. Where should the data be json data? I don't know how to return the json data. The website uses jQuery to submit it, the submitted code is as follows:

$.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");},


How should I use a program to simulate the submission process? is there a different format for submitting json?


Reply to discussion (solution)

$. Ajax ('/index. php/game/postcode' can I submit it to php successfully?

$. Ajax ('/index. php/game/postcode' can I submit it to php successfully?



Yes

When you return json data in a php script, use json_encode ($ arr) to process it.

When you return json data in a php script, use json_encode ($ arr) to process it.



I want to know how these parameters are transmitted in the past. if they are changed to a URL, how should they be simulated? How can I simulate sending without ajax?

The data submitted by post is processed by urlencode. Use curl to simulate post submission.
Urlencode:
Returns a string -_. all other non-alphanumeric characters will be replaced with a semicolon (%) followed by two hexadecimal numbers, and spaces will be encoded as the plus sign (+ ). This encoding method is the same as that for WWW form POST data, and the same as that for application/x-www-form-urlencoded

The data submitted by post is processed by urlencode. Use curl to simulate post submission.
Urlencode:
Returns a string -_. all other non-alphanumeric characters will be replaced with a semicolon (%) followed by two hexadecimal numbers, and spaces will be encoded as the plus sign (+ ). This encoding method is the same as that for WWW form POST data, and the same as that for application/x-www-form-urlencoded



I am not able to answer this question.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.