2013-10-22 52 views
0

我需要一個ASP.NET MVC4 Ajax表單與一個提交按鈕和DropDownLists張貼在變化。ASP.NET MVC4手動AJAX後wihtout驗證

問題是,當我使DropDownList更改時手動ajax帖子我想關閉JavaScript驗證。

當我在SelectedShiftModel中更改選擇時,這是響應,但只有在單擊提交按鈕時才需要此選項。

enter image description here

我做手工阿賈克斯後這樣說:

$(document).ready(function() { 
    $('#SelectedShiftModel').change(function() { 
     var postData = $("#PostData").serialize(); 
     $.post("Create", postData, function (data) { 
      $('#Fields').html($(data).find('#Fields').html()); 
     }); 
    }); 
}); 

回答

0

這是很少的代碼就知道如何幫助你。但是從我看到你在帖子後添加表單到屏幕上。當表單從服務器返回時,它可能具有ModelState.IsValid = false。你可以做的是清空錯誤字典。

看看這裏mvc3-remove-modelstate-errors

+0

ModelState.Clear(); < - 這使它。 – jannagy02

+0

很高興幫助。 – hjgraca