开发者

Jquery Popup and JSon issue in MVC

I have a couple of TextBox controls in a JQuery Popup:

       <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></la开发者_C百科bel>
            <%= Html.TextBox("AmountPerMWIC") %>
            <%= Html.ValidationMessage("AmountPerMWIC", "*")%>
        </li> 

I have some JQuery and JSON to update the view behind the popup (cut for brevity):

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 {

My problem is that ****data.AmountPerTurbine** is always undefined.** THe other fields are all fine.

It even passes the correct data back to the controller and saves correctly but I cannot update my view correctly.

I have checked my model and bindings etc. Everything works fine up to this point.

Any ideas would be graetly appreciated.


Eventually tracked down to an embarrassing typo.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜