Home > front end >  Login to write a small function, the background can be normal return data, but the reception error 4
Login to write a small function, the background can be normal return data, but the reception error 4

Time:09-15

The background code
 
@ RequestMapping ("/login ")
@ ResponseBody
Public ResultModel login (@ RequestParam (value="https://bbs.csdn.net/topics/userName", defaultValuehttps://bbs.csdn.net/topics/="") String userName, @ RequestParam (value=" https://bbs.csdn.net/topics/password ", defaultValuehttps://bbs.csdn.net/topics/="") String password) {
ResultModel ResultModel=new ResultModel<> (a);
List List=usersService. Login (userName, password);
ResultModel. SetData (list);
System. The out. Println (" login method return parameter: the result="+ resultModel);
Return resultModel;
}

The foreground part code js
 
//login
$(" # toLogin "). Click (function () {
Var userName=$(" # userName "). Val ();
Var password=$(" # "password," "). Val ();
$. Ajax ({
Url: "/h5/index/login,"
Data: {
"UserName" : the userName,
"Password" : "
},
Type: "GET",
Success: the function (response) {
If (response. Code=="000000") {
Var data=https://bbs.csdn.net/topics/response.data;
If (data. The length & gt; 0 {
If ($(" # userName "). The val ()==data. The userName & amp; & $(" # "password," "). Val ()==data. The password) {
Layer. MSG (" login successfully!" );
}
}
} else {
Layer. MSG (" username or password is not correct!" );
}
},
Error: function () {
Layer. MSG (" connection failed! Please try again after checking the network!" {2} icon:);
}
})
})

CodePudding user response:

405 request way is not correct

CodePudding user response:

Type: "POST"

CodePudding user response:

To POST will still be at 405

CodePudding user response:

Error - 405 general solution

405 error and POST method often appear at the same time, you may have on your website try to introduce some kind of input forms, but not all Internet service providers (ISPs) are allowed to deal with the form required POST method,

All 405 error can be chased to sum to the Web server Settings, and safety management to control access to Web content, so your ISP should be easy to explain,

Quoted from
https://blog.csdn.net/qq_35804654/article/details/77272304

CodePudding user response:

Look at the console error

CodePudding user response:

bosses have a look
  • Related