脚本宝典收集整理的这篇文章主要介绍了php – jQuery ajax回到$_POST而不是REQUEST有效负载,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
<script tyPE="text/javascript"> $(document).on('submIT','.ajaxform',function(e){ e.preventDefault(); VAR datastring = $(this).serialize(); $.ajax({ type: "POST",data: datastring,contentType: "application/json; charset={CHARSET}",dataType: "json",beforeSend: function(){ console.LOG($(this).serialize()); },success: function(data){ alert('yes'); },error: function(errMsg){ alert('error'); } }); }); </script> <form action="" id="register" name="register" class="ajaxform" method="post" enctype="multipart/form-data"> <input type="text" name="username" value="" /> <input type="password" name="password" value="" /> <input type="hidden" name="action" value="register" /> <input type="hidden" name="{TOKENID}" value="{TOKEN}" /> <input type="submit" value="Register" /> </form>
提交后,我无法通过键入$_POST [‘username’]来获取输入字段值.
我检查了检查元素,我注意到有些不同.
Request URL:http://PRoject0/member.PHP Request Method:POST status Code:200 OK ... ... Content-type:application/json; charset=UTF-8 ... ... Request payload: username=asd&password=asd&action=register&29cd5e5ca1=73050db390872eb7c3fc564206b961c59a6363d6
contentType: "application/json; charset={CHARSET}"
contentType: "application/x-www-form-urlencoded; charset=UTF-8"
以上是脚本宝典为你收集整理的php – jQuery ajax回到$_POST而不是REQUEST有效负载全部内容,希望文章能够帮你解决php – jQuery ajax回到$_POST而不是REQUEST有效负载所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。