MVC3 - Ajax loading icon

前端 未结 3 451
攒了一身酷
攒了一身酷 2021-02-02 04:15

I would like to show an AJAX loading icon during an ActionResult request that can take a few seconds to process.

What is the best approach to accomplished this?

3条回答
  •  野性不改
    2021-02-02 04:27

    Define your link as an Ajax action link and specify the ID of a spinning GIF somewhere on your page.

    @Ajax.ActionLink("Link Text", "ActionName", "ControllerName", null, new AjaxOptions{UpdateTargetId = "result", LoadingElementId = "spinner"}, null)

    or if it is a form:

    @using(Ajax.BeginForm("Action", "Controller", null, new AjaxOptions{UpdateTargetId = "result", LoadingElementId = "spinner"}, null))
    {
       @Html.TextBox("Data")
    }

提交回复
热议问题