javascript - 用js自寫ajax提交表單資料到php,但是php的$_POST為空白?

來源:互聯網
上載者:User

,這是接收表單資料的php控制器,有Form Data資料傳進去了,但是php的$_REQUEST中只有$_GET的資料,沒有$_POST的資料,這是為什嗎?(應該不用看代碼吧?如需看代碼,說一下,我再補上去)

//這是的文本版Remote Address:127.0.0.1:80Request URL:http://localhost/app/index.php?c=member&a=submit&random=0.122100246604532Request Method:undefinedStatus Code:200 OKRequest HeadersAccept:*/*Accept-Encoding:gzip, deflate, sdchAccept-Language:zh-CN,zh;q=0.8,en;q=0.6,zh-TW;q=0.4,fr;q=0.2Connection:keep-aliveContent-Length:42Content-type:application/x-www-form-urlencodedCookie:cityId=18; CNZZDATA1252926391=1013903247-1419300217-%7C1421816418; PHPSESSID=3fltaetqosqt69uqj9hd8imr77Host:localhostOrigin:http://localhostReferer:http://localhost/app/index.php?c=makeFactory&a=getVideoFileUser-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.4Query String Parametersc:membera:submitrandom:0.122100246604532Form Dataview sourcecontent:0video_id:908price:0label_id:11Response HeadersCache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0Connection:Keep-AliveContent-Length:80Content-Type:text/htmlDate:Sun, 01 Mar 2015 02:50:07 GMTExpires:Thu, 19 Nov 1981 08:52:00 GMTKeep-Alive:timeout=5, max=100Pragma:no-cacheServer:Apache/2.2.17 (Win32) PHP/5.3.3X-Powered-By:PHP/5.3.3

回複內容:

,這是接收表單資料的php控制器,有Form Data資料傳進去了,但是php的$_REQUEST中只有$_GET的資料,沒有$_POST的資料,這是為什嗎?(應該不用看代碼吧?如需看代碼,說一下,我再補上去)

//這是的文本版Remote Address:127.0.0.1:80Request URL:http://localhost/app/index.php?c=member&a=submit&random=0.122100246604532Request Method:undefinedStatus Code:200 OKRequest HeadersAccept:*/*Accept-Encoding:gzip, deflate, sdchAccept-Language:zh-CN,zh;q=0.8,en;q=0.6,zh-TW;q=0.4,fr;q=0.2Connection:keep-aliveContent-Length:42Content-type:application/x-www-form-urlencodedCookie:cityId=18; CNZZDATA1252926391=1013903247-1419300217-%7C1421816418; PHPSESSID=3fltaetqosqt69uqj9hd8imr77Host:localhostOrigin:http://localhostReferer:http://localhost/app/index.php?c=makeFactory&a=getVideoFileUser-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.4Query String Parametersc:membera:submitrandom:0.122100246604532Form Dataview sourcecontent:0video_id:908price:0label_id:11Response HeadersCache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0Connection:Keep-AliveContent-Length:80Content-Type:text/htmlDate:Sun, 01 Mar 2015 02:50:07 GMTExpires:Thu, 19 Nov 1981 08:52:00 GMTKeep-Alive:timeout=5, max=100Pragma:no-cacheServer:Apache/2.2.17 (Win32) PHP/5.3.3X-Powered-By:PHP/5.3.3

注意到你的Request Method是Undefined,這個地方應該是POST。
你可以:
1、把AJAX提交的方式設定為post
2、最好把表單的method設為post,method="post"

$_POST可以得到資料嘛?還是放上控制器的代碼吧

待補充。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.