I have looked into Ajax only recently (laugh at me you experts), and I feel excited about all the added functions. But there are a few concerns.
Form submission
In the Ajax examples, a json object is created either automatically (serialize the form) or manually built by retrieving val() from each DOM items. And data validation is performed using javascript. I think we can probably still use Html.EditorFor (and Html.TextboxFor etc.) to build the form. But is it possible to still use the DataAnnotation attributes added on the model/viewmodel? The MVC+Ajax examples I have seen usually don't perform any type of server side validation. Is it okay to omit that part? I guess it is fine because a user has to have javascript enabled to submit the form now. But we need some professional suggestions.
View Models
In the Ajax world, the View Models are usually expressed as a JSON object. (Please correct me if I am wrong.) Then, what is the best way to map between our domain model and the view model? Is there any tools like AutoMapper?
Okay, I need to add something here...........
The reason for this concern is that I have found some examples use something called
Knockout.js(See its website) Instead ofreturn Json(model)to return a json object of our view model into the$.Ajaxcall, its examples shows a view model is built in javascript.// This is a simple *viewmodel* - JavaScript that defines the data and behavior of your UI function AppViewModel() { this.firstName = "Bert"; this.lastName = "Bertington"; } // Activates knockout.js ko.applyBindings(new AppViewModel());What is the benefit of such practice?
---- end of my update ----
Thank you for any helpful suggestions.