|
- 导入jquery
- <script src="~/lib/jquery/dist/jquery-3.3.1.js" type="text/javascript"></script>
复制代码 -
在js脚本中写Ajax - function FormAjax(){
- $.ajax({
- url: "Register/RegisterResult",
- data: {
- "phone": phone, "verification_code": verification_code,
- "password": password, "password_again": password_again
- },
- type: "post",
- dataType:"text",
- success: function (response) {
- alert(response);
- }
- });
- }
复制代码 - HTML5中使用
- <input id="register_btn" onClick="FormAjax();" type="submit" value="立即注册">
复制代码 -
控制器RegisterController中使用 - public string RegisterResult()
- {
- RegisterViewModel register = new RegisterViewModel();
- register.MobilePhone = Request.Form["phone"];
- register.VerificationCode = Request.Form["verification_code"];
- register.Password = Request.Form["password"];
- register.PasswordAgain = Request.Form["password_again"];
- if (register.MobilePhone!=""&®ister.VerificationCode!=""
- &®ister.Password!=""&®ister.PasswordAgain!="")
- {
- return "ok";
- }
- else{
- return "false";
- }
- }
复制代码
来源:https://blog.csdn.net/qq_37665834/article/details/84191035 免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |
|