View not refreshing after AJAX post

前端 未结 3 1749
小蘑菇
小蘑菇 2020-12-16 18:27

I have a view (Index.cshtml) with a grid (Infragistics JQuery grid) with an imagelink. If a user clicks on this link the following jquery function will be called:

         


        
3条回答
  •  无人及你
    2020-12-16 18:56

    As you requesting AJAX call, you should redirect using its response

    Modify your controller to return JSONResult with landing url:

    public ActionResult SetEnddateRemarkToYesterday(int remarkID) {
        //Some logic to persist the change to DB.
        var redirectUrl = new UrlHelper(Request.RequestContext).Action("Index", "Controller");
            return Json(new { Url = redirectUrl });
    }
    

    JS Call:

    $.post("Home/SetEnddateRemarkToYesterday", { remarkID: remarkID },  function (result) {
        window.location.href = result.Url
    });
    

提交回复
热议问题