JQuery的面對的問題,同時提交表單 - 「500內部服務器錯誤」
$(document).ready(function() {
var EmailContainer = $('#EmailContainer');
var url = EmailContainer.attr('data-url');
EmailContainer.load(url, function() {
var Emailform = $('#EmailForm');
$.validator.unobtrusive.parse(Emailform);
Emailform.submit(function() {
debugger;
var Emailform = $(this);
if (Emailform.valid()) {
var SendEmailUrl = EmailContainer.attr('Json-Url');
var UserModel = { From: $('#From').val(), To: $('#To').val(),
Subject: $('#Subject').val(),
Description: $('#Description').val() }
$.post(SendEmailUrl, UserModel, function (data) {
Emailform.html(data);
Emailform.removeData('validator');
Emailform.removeData('unobtrusiveValidation');
$.validator.unobtrusive.parse(Emailform);
});
}
return false;
});
});
});
管理控制器管窺
@model _1.Areas.Email.Models.User
@using (Html.BeginForm("SendEmail", "Admin", FormMethod.Post, new { id = "EmailForm" }))
{
@Html.LabelFor(i => i.From);
@Html.TextBoxFor(i => i.From);
@Html.ValidationMessageFor(i => i.From);
<br />
@Html.LabelFor(i => i.To);
@Html.TextBoxFor(i => i.To);
@Html.ValidationMessageFor(i => i.To);
<br />
@Html.LabelFor(i => i.Subject);
@Html.TextBoxFor(i => i.Subject);
@Html.ValidationMessageFor(i => i.Subject);
<br />
@Html.LabelFor(i => i.Description);
@Html.TextBoxFor(i => i.Description);
@Html.ValidationMessageFor(i => i.Description);
<br />
<input type="submit" value="Send Email" id="SendMail" />
}
問題 - 當提交管理控制器的局部視圖。它給「500內部服務器錯誤」
更新 - 1
正如你可以在局部視圖看到 - 我提的HTML.BeginForm的行動,也有我提交表格。我認爲請求已被提交多次?
你需要指定錯誤是什麼。開發工具中的響應標籤應該顯示它。 – 2013-02-19 12:25:17
更新了我的查詢。請檢查。 – SMC 2013-02-19 12:28:11