- asp.net mvc model object is being fetched by ajax call – $.ajax(….
- form has fields with IDs exactly to matching properties on returned json object (created by
Html.TextBox("NAME", Model.Order.NAME))
How to automatically populate fields(inputs) with corresponding json object properties ?
Manually would be like $("#NAME).val(json.NAME) so how to make this dynamic?
Is there some kind of reflections (like System.Reflection in c#) for javascript/jquery ?
Maybe something like this:
… which iterates over all the form inputs, and looks for a JSON entry with the inputs ID.
The thing to note here is that you can retrieve
json.NAMEviajson["NAME"].