MVC5与ajax前后台交互

时间:2025-02-14 18:39:05

前台:

$.ajax({
                async: true,
                type: "post",
                url: "AutoDataNo",
                data: { "type": "Hi" },
                dataType: "json",
                success: function (data) {
                    $("#DataNo").val(data);
                }
            })

后台:

 [HttpPost]
        public JsonResult AutoDataNo(string type)
        {
            return Json(type);
        }