Index.aspx:

<script src="../../Scripts/jquery-1.3.2.js" type="text/javascript"></script>
    
    <script type="text/javascript">
        function getMessage() {
            $.get("/SimpleAjax/GetMessage", function(data) {
                $("#result").html(data);
            });
        }
    </script>
 
<button type="button" onclick="getMessage();">Get the Message!</button>
<div id="result"></div>

 

SimpleAjaxController.cs:

public class SimpleAjaxController : Controller
    {   
        public ActionResult Index()
        {
            return View();
        }
 
        public ActionResult GetMessage()
        {
            return Content("<h1>This is a custom message returned from an action.</h1>");
        }
    }

相关文章:

  • 2021-06-23
  • 2021-09-13
  • 2021-09-24
  • 2021-11-29
  • 2021-06-29
  • 2022-12-23
  • 2021-08-04
  • 2022-12-23
猜你喜欢
  • 2021-12-24
  • 2021-10-23
  • 2021-10-17
  • 2022-01-30
  • 2022-01-03
  • 2021-11-28
  • 2021-07-10
相关资源
相似解决方案