Submit form via ajax to server and check if there were any errors
Any experienced full stack web developer here? I need some help regarding validating a form via javascript and then submitting it on server. What i am trying to do is validate a form via javascript, if form is validated, i send this form to server via ajax. If server sends any error, i call a javascript function to display that error message. This didn't work for me and on top of that someone informed me that this isn't a safe way to do it. I asked a question on stackoverflow (https://stackoverflow.com/questions/50348267/check-if-form-has-been-submitted-via-ajax-in-php) but i haven't gotten a solution yet. Can someone please guide me on this. Please refer to link to my question on stackoverflow for more context. Question is HOW CAN I achieve what i am trying to do and in a secure way ?