html form post json,javascript - How to post a complex HTML form as JSON? - Stack Overflow

余铭晨
2023-12-01

I have a very complex form in a web page. User actually builds up a complex object. The UI is handled using jQuery (showing, hiding sections, duplicating and deleting sub-forms,...).

Simply posting the form upon user submission, although possible, doesn't seem the best solution: It would be hard to makeup unique names for fields (there can be arrays of objects) and to decode the whole stuff on server side.

I guess I should rather post a JSON representation of the object. How do I do that?

I'm not trying to make an ajax call. I want to submit the form but using JSON instead of an usual application/x-www-form-urlencoded form.

FWIW, the backend is ASP.NET MVC.

TIA,

 类似资料: