表单提交+异步请求
@{ Layout = null; } <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width" /> <script src="~/Scripts/jquery-1.8.2.js"></script> <title>Add</title> <script type="text/javascript"> function LoadByAjax(formId) { var form = $("#" + formId); $.ajax({ url: form.attr("action"), type: 'post', data: form.serialize(), success: function (data) { console.log(data); }, error: function () { alert("请求出错"); } }); } </script> </head> <body> <div> <form id="formText" onsubmit="return false" action="/Home/Text" method="post"> <input type="text" name="UserName" value="" /> <input type="password" name="Password" value="" /> <button type="submit" onclick="LoadByAjax('formText')">测试按钮</button> </form> </div> </body> </html>