(Jquery Ajax Call )Post 一个Form去后台以及AJAX call后DIV重新加载

               

  

      



 $("#signinbtn1").click(function () {
            $.ajax({
                url: "/Customer/LoginPartial",
                type: "POST",
                dataType: "json",
                data: $("#signinform1").serialize(),
                error: function (xhr) {
                },
                success: function (json) {
                    json = json || {};
                    if (json.success) {
                        $("#headerlinkdiv").load("/Common/HeaderLinks");         //DIV重新加载
                        $(".modal-backdrop").remove();
                        //window.location = json.redirect || location.href;
                    } else if (json.errors) {
                        displayErrors($("#signinform1"), json.errors);
                    }
                }
            });
        });

 

@Html.Action("HeaderLinks", "Common")

 public JsonResult LoginPartial(LoginModel model, string returnUrl)
        {
             var errors = new { errors = ModelState.SelectMany(x => x.Value.Errors.Select(error => error.ErrorMessage)) };
            if (errors.errors.Count() > 0)
            {
                return Json(errors);
            }
            else 
            {
                return Json(new { success = true, redirect = returnUrl }); 
            }
            
        }

你可能感兴趣的:(.NET)