View not refreshing after AJAX post

前端 未结 3 1728
小蘑菇
小蘑菇 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:46

    After Ajax post you need to call to specific Url.. like this.. window.location.href = Url

    0 讨论(0)
  • 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
    });
    
    0 讨论(0)
  • 2020-12-16 18:57

    When using jQuery.post the new page is returned via the .done method

    jQuery

    jQuery.post("Controller/Action", { d1: "test", d2: "test" })
      .done(function (data) {
          jQuery('#reload').html(data);
      });
    

    HTML

    <body id="reload">
    
    0 讨论(0)
提交回复
热议问题