<meta name="viewport" content="width=device-width" />
<title>JQuery Dialog Demo</title>
<link href="https://ajax.aspnetcdn.com/ajax/jquery.ui/1.12.1/themes/vader/jquery-ui.css" rel="stylesheet" />
@using (Ajax.BeginForm(actionName: "GetFakeData", ajaxOptions: new AjaxOptions
OnSuccess = "GetFakeDataSuccess"
<label>AjaxHelper版本查詢</label>
<input type="text" name="name" value="ITWeiHan" />
<input type="submit" value="查詢" />
<label>JQueryAjax版本查詢</label>
<input type="text" name="name" value="ITWeiHan" />
<div id="dialog" title="Dialog視窗"></div>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://ajax.aspnetcdn.com/ajax/jquery.unobtrusive-ajax/3.2.5/jquery.unobtrusive-ajax.js"></script>
<script src="https://ajax.aspnetcdn.com/ajax/jquery.ui/1.12.1/jquery-ui.min.js"></script>
function GetFakeDataSuccess(obj) {
var dialog = $("#dialog");
dialog.html(`名字 : ${obj.Name}`);
$('button').on('click', function () {
url: '@Url.Action("GetFakeData", "Home")',
data: $("#formID").find('select, textarea, input').serialize(), /*假如想要在Div像Form序列化,可以使用find input*/
success: function (obj) { GetFakeDataSuccess(obj); },
error: function (e) { console.log(e); }