我有一个注册表,成功注册后,它会重定向到另一个视图。
我使用提交按钮将数据插入数据库,我想清除当前视图中的值,并将用户重定向到同一控制器下另一个视图中的logon page
提交类型未执行jquery中提到的操作。请帮助我

这是我的代码预览

Account/register

Account/logon

 Accountcontroller.cs
      [HttpPost]
     public ActionResult Register(RegisterModel model, FormCollection form)
      {
           try {
                ---code
               }
           catch {
           }
      }

register.cshtml
     @using (Html.BeginForm("Register", "Account", FormMethod.Post, new { id = "accForm"      }))
           {
             @html.textboxfor(.....)
             @html.textboxfor(.....)
             @html.textboxfor(.....)
             @html.textboxfor(.....)
                    ....
          <input type="submit" value="CreateAccount" class="buttonclass"               title="CreateAccount" ; onclick="SaveUser(this);"

             }

    function SaveUser(btnClicked) {
           alert("clear");
           document.getElementById("regname").value = '';
           document.getElementById("regusername").value = '';
           document.getElementById("regemail").value = '';
           document.getElementById("regpassword").value = '';


           document.getElementById("regpassword2").value = '';

           $.ajax({
                   url: window.location.pathname + '/Account/Logon',

                   type: 'GET',
               })
               .success(function (result) {
                    alert("user saved successfully");
                     });


更新:


   function SaveUser(btnClicked) {

       document.getElementById("regname").value = '';
       document.getElementById("regusername").value = '';
       document.getElementById("regemail").value = '';
       document.getElementById("regpassword").value = '';
       document.getElementById("regpassword2").value = '';
       alert('clear');
   $.ajax({


          type: "POST",
           url:  window.location.pathname + "Account/Register",

           success: function (response) {
               $.ajax({
                   url: window.location.pathname + '/Account/Logon',
                   type: 'GET',
               })
        .success(function (result) {
            alert("user saved successfully");

            // window.location ="";
        });
           },
           error: function (xhr, status, error) {
               alert("Failed");
           }
       });
}


我收到失败警报。
请帮忙

最佳答案

如果要在SuccessFul登录上重定向页面,则在成功上编写重定向代码(ajax成功)。
经验值:

$.ajax({
        url: window.location.pathname + '/Account/Logon',
        type: 'GET',
         })
         .success(function (result) {
                    alert("user saved successfully");

         // window.location ="";
          });

10-08 03:16