亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

關于Axios的使用問題

關于Axios的使用問題

UYOU 2019-08-21 13:42:47
今天,我使用Axios寫注冊的AJAX提交JS,它可以正常的發送請求,但我發現后端完全無法正常接受前端傳來的username和password信息,我應該如何修復這個BUG?謝謝。部分JS代碼(jQuery):varcaptcha_res_ticket=$.cookie("captcha.res.ticket");varcaptcha_res_randstr=$.cookie("captcha.res.randstr");varusername=$("#inputUsername").val();varemail=$("#inputEmail").val();varpassword=$("#inputPassword").val();varrepassword=$("#inputRepassword").val();varagree_user_agreement=$("#agree_user_agreement").is(":checked");varparticipate_in_the_user_experience_program=$("#participate_in_the_user_experience_program").is(":checked");Axios部分代碼:axios({url:'/user/user_registration/php/registration.php',method:'post',timeout:3000,data:{captcha_res_ticket:captcha_res_ticket,captcha_res_randstr:captcha_res_randstr,username:username,email:email,password:password}})Captcha來自我的驗證碼API。
查看完整描述

2 回答

?
慕蓋茨4494581

TA貢獻1850條經驗 獲得超11個贊

Axios部分代碼(JS):
constparams=newURLSearchParams();
params.append('captcha_res_ticket',captcha_res_ticket);
params.append('captcha_res_randstr',captcha_res_randstr);
params.append('username',username);
params.append('password',password);
axios({
url:'/user/user_login/php/login.php',
method:'post',
timeout:1000,
data:params
})
                            
查看完整回答
反對 回復 2019-08-21
?
慕尼黑8549860

TA貢獻1818條經驗 獲得超11個贊

超全局變量$_POST無法接受content-type:application/json的請求body。
解決方案
echofile_get_contents('php://input');
                            
查看完整回答
反對 回復 2019-08-21
  • 2 回答
  • 0 關注
  • 227 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號