ajax post请求报500,为什么post 提交后,还没执行 Ajax 就报500错,什么原因呢?

*reset_pwd.js*

;

var user_resetPwd_opt = {

init: function(){

this.bindEvent();

},

bindEvent: function(){

var that = this;

$("#save").click(function(){

var btn_target = $(this);

if( btn_target.hasClass("disabled") ){

alert("正在处理,请不要频繁点击~~");

return;

}

var old_password = $("#old_password").val();

if(!old_password){

alert("请输入原密码~~",$("#old_password"));

return false;

}

var new_password = $("#new_password").val();

if(!new_password || new_password.length<6){

alert("请输入不少于6位的新密码!",$("#new_password") );

return false;

}

btn_target.addClass("disabled");

var data = {

'old_password':$("#old_password").val(),

'new_password':$("#new_password").val()

};

//执行到这里,就不往下执行了,ajax方法中都不进去,然后报 500 错

$.ajax({

url:'/web/user/reset-pwd',

type:'POST',

data:data,

dataType:'json',

success:function(res){

console.log(res);

btn_target.removeClass("disabled");

var callback = null;

if( res.code == 200 ){

callback = function(){

window.location.href = window.location.href;

}

}

common_ops.alert( res.msg,callback );

}

});

});

}

};

$(function(){

user_resetPwd_opt.init();

});

*php 接口文件*

//修改密码,这个接口方法也不执行!!!根本进不来

public function actionResetPwd(){

if( \Yii::$app->request->isGet){

return $this->render("reset_pwd",[

'info' => $this->current_user

]);

}

$old_password = trim($this->post('old_password',''));

$new_password = trim($this->post('new_password',''));

var_dump($old_password);

if(!$old_password){

return $this->renderJSON([],"请输入原密码!",-1);

}

if( mb_strlen($new_password,"utf-8") < 6 ){

return $this->renderJSON([],"请输入不少于6位的新密码!",-1);

}

if($old_password == $new_password){

return $this->renderJSON([],"请重新输入一个吧,新密码和原密码不能相同哦!",-1);

}

$current_user = $this->current_user;

if (!$current_user->verifyPassword($old_password)) {

return $this->renderJSON([],"请检查原密码是否正确~~",-1);

}

if( $current_user['uid'] == 2 ){

return $this->renderJSON([],"该账号为测试账号,请不要修改密码~~",-1);

}

$current_user->setPassword($new_password);

$current_user->updated_time = date("Y-m-d H:i:s");

$current_user->update(0);

$this->setLoginStatus( $current_user );

return $this->renderJSON([],"修改成功~~");

}

以下为返回的 500 提示信息,网上找了好久了,都没有找到对应的解决办法:

Request URL: http://localhost/web/user/reset-pwd

Request Method: POST

Status Code: 500 Internal Server Error

Remote Address: [::1]:80

Referrer Policy: no-referrer-when-downgrade

Connection: close

Content-Length: 1086

Content-Type: text/html; charset=UTF-8

Date: Wed, 07 Aug 2019 14:34:05 GMT

Server: Apache/2.4.39 (Win64) PHP/7.2.18

X-Debug-Duration: 52

X-Debug-Link: /debug/default/view?tag=5d4ae15d5a12f

X-Debug-Tag: 5d4ae15d5a12f

X-Powered-By: PHP/7.2.18

Accept: application/json, text/javascript, */*; q=0.01

Accept-Encoding: gzip, deflate, br

Accept-Language: zh-CN,zh;q=0.9

Cache-Control: no-cache

Connection: keep-alive

Content-Length: 43

Content-Type: application/x-www-form-urlencoded; charset=UTF-8

Cookie: _csrf=c0529d0c9fadbedf960423cd3d1160852fa4528d1ca9477ae5b7ecc462d6dd47a%3A2%3A%7Bi%3A0%3Bs%3A5%3A%22_csrf%22%3Bi%3A1%3Bs%3A32%3A%22zOrm1uMkflCmSJt-e64VkAsVzHNAqA7U%22%3B%7D; SL_G_WPT_TO=zh-CN; SL_GWPT_Show_Hide_tmp=undefined; SL_wptGlobTipTmp=undefined; mooc_book=117caee042eb7b1cb219735ee3732fe9aa7ebf78321d05c7a78b8a62739d9e24a%3A2%3A%7Bi%3A0%3Bs%3A9%3A%22mooc_book%22%3Bi%3A1%3Bs%3A34%3A%22143af06bfcb66cc61e2f0aa96abfe0f5%231%22%3B%7D

Host: localhost

Origin: http://localhost

Pragma: no-cache

Referer: http://localhost/web/user/reset-pwd

User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36

X-Requested-With: XMLHttpRequest

old_password: 123456

new_password: root123456

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值