桃花長(zhǎng)相依
2019-06-15 17:27:49
在ASP.NETMVC 3 Razor中使用Ajax.BeginForm是否有教程或代碼示例使用Ajax.BeginForm在ASP.NETMVC 3中,是否存在不引人注目的驗(yàn)證和Ajax?對(duì)于MVC 3來(lái)說(shuō),這是一個(gè)難以捉摸的話(huà)題,而且我似乎無(wú)法使我的表單正常工作。它將執(zhí)行Ajax提交,但忽略驗(yàn)證錯(cuò)誤。
3 回答

慕工程0101907
TA貢獻(xiàn)1887條經(jīng)驗(yàn) 獲得超5個(gè)贊
<div id="target"> @using (Ajax.BeginForm("MyAction", "MyController", new AjaxOptions { HttpMethod = "POST", InsertionMode = InsertionMode.Replace, UpdateTargetId = "target" })) { <!-- whatever --> } </div>

縹緲止盈
TA貢獻(xiàn)2041條經(jīng)驗(yàn) 獲得超4個(gè)贊
var form = $(this);
$(document).on("submit", "form", function (event) { var form = $(this); if (form.valid()) { $.ajax({ url: form.action, // Not available to 'form' variable type: form.method, // Not available to 'form' variable data: form.serialize(), success: function (html) { // Do something with the returned html. } }); } event.preventDefault();});
$.ajax({ url: this.action, type: this.method, data: $(this).serialize(), success: function (html) { // Do something with the returned html. }});
添加回答
舉報(bào)
0/150
提交
取消