How to display confirmation after the form has been generated via Ajax

I try my best to find the best way to display validation messages after the form created using ajax is submitted.

Let me explain better:
I have a page that starts with several options. Based on what the user selects from the drop-down lists and adding new fields, the form is created and the form is sent at the end.

The problem is that even if I can perform verification checks on the server and display a general verification message on the page. How to pre-fill the form fields with the values ​​entered by the user before clicking the submit button.

+3
source share
2 answers

Three options:

  • regular POST -> the server displays the AS form in which it was submitted (you should be able to rebuild the server side of the form)

  • ajax POST -> just redirect the user if the check was successful

  • check before sending -> synchronous ajax check calls

+1
source

There were several ways I could handle this.

1) Make another AJAX call on the view, which performs checks and returns without a full record. This is not an elegant solution, as it involves two round trips and, depending on the validation, will lead to performance problems.

2) json, , 2 json. , . , , .

; , .

0

Source: https://habr.com/ru/post/1734254/


All Articles