我在jquery弹出窗口中有几个文本框控件:
<li id="lblAmountPerTurbine">
<label for="AmountPerTurbine"><strong>Amount Per Turbine:</strong></label>
<%= Html.TextBox("AmountPerTurbine")%>
<%= Html.ValidationMessage("AmountPerTurbine", "*")%>
</li>
<li id="lblAmountPerMWIC">
<label for="AmountPerMWIC"><strong>Amount Per MWIC:</strong></label>
<%= Html.TextBox("AmountPerMWIC") %>
<%= Html.ValidationMessage("AmountPerMWIC", "*")%>
</li>
我有一些jquery和json来更新弹出窗口后面的视图(为了简洁而剪切):
function ElementSave(e) {
//get the data into an array to pass to controller
var fixedElementData = $('#Element_InputDiv').find(':input').serializeArray();
//build the url based on the save type
if ($('#PaymentFixedElementId').val() != 0)
var url = '/PaymentFixed/EditElement/' + $('#PaymentFixedElementId').val();
else
var url = '/PaymentFixed/CreateElement/' + +$('#PaymentFixedId').val();
//post the new invoice to the controller action and deal with the call back
$.post(url,
fixedElementData,
function(data) {
//if the controller returns errors then display, otherwise add to grid
if (data.errors != null) {
$('#ErrorDiv').html(data.errors);
}
else {
我的问题是****data.amountPerturbine**总是未定义的。**其他字段都可以。
它甚至将正确的数据传回控制器并正确保存,但我无法正确更新视图。
我已经检查了我的模型和绑定等。到目前为止一切都正常。
任何想法都会受到赞赏。