javascript - 用js自写ajax提交表单数据到php,但是php的$_POST为空?
ringa_lee
ringa_lee 2017-04-10 14:57:04
0
2
793

如图,这是接收表单数据的php控制器,有Form Data数据传进去了,但是php的$_REQUEST中只有$_GET的数据,没有$_POST的数据,这是为什么?(应该不用看代码吧?如需看代码,说一下,我再补上去)

//这是上图的文本版
Remote Address:127.0.0.1:80
Request URL:http://localhost/app/index.php?c=member&a=submit&random=0.122100246604532
Request Method:undefined
Status Code:200 OK

Request Headers
Accept:*/*
Accept-Encoding:gzip, deflate, sdch
Accept-Language:zh-CN,zh;q=0.8,en;q=0.6,zh-TW;q=0.4,fr;q=0.2
Connection:keep-alive
Content-Length:42
Content-type:application/x-www-form-urlencoded
Cookie:cityId=18; CNZZDATA1252926391=1013903247-1419300217-%7C1421816418; PHPSESSID=3fltaetqosqt69uqj9hd8imr77
Host:localhost
Origin:http://localhost
Referer:http://localhost/app/index.php?c=makeFactory&a=getVideoFile
User-Agent:Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.3 (KHTML, like Gecko) Version/8.0 Mobile/12A4345d Safari/600.1.4

Query String Parameters
c:member
a:submit
random:0.122100246604532

Form Dataview source
content:0
video_id:908
price:0
label_id:11

Response Headers
Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:Keep-Alive
Content-Length:80
Content-Type:text/html
Date:Sun, 01 Mar 2015 02:50:07 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive:timeout=5, max=100
Pragma:no-cache
Server:Apache/2.2.17 (Win32) PHP/5.3.3
X-Powered-By:PHP/5.3.3
ringa_lee
ringa_lee

ringa_lee

Antworte allen(2)
洪涛

注意到你的Request Method是Undefined,这个地方应该是POST。
你可以:
1、把AJAX提交的方式设置为post
2、最好把表单的method设为post,method="post"

洪涛

$_POST可以得到数据嘛?还是放上控制器的代码吧

待补充。

Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage