Quantcast
Channel:
Viewing all articles
Browse latest Browse all 4235

Appropriate approach to failed server side validation return to ajax?

$
0
0

I have a form on a site I am building which is posted via ajax. It first runs through jQuery validate plugin validation, and on success POSTS through ajax.

If the form has been filled out correctly, all works well. But if for whatever reason client-side validation succeeds when it shouldn't have, when the ajax POST is made, the form detects a validation error (e.g. blank required name) & returns the full template HTML for the rendered page.

Because Ajax is POST'ing the form data, is there a way to manipulate the response? Rather than sending through the template HTML, return an json object of validation errors?

Looking into framework's form.php, I see the method getValidationErrorResponse. I guess I could subclass form and write my own getValidationErrorResponse to manage how the response is handled? However, is there something already pre-built into SS to manage this type of situation?


Posted to: Appropriate approach to failed server side validation return to ajax? | Show Thread | Post Reply


Viewing all articles
Browse latest Browse all 4235

Trending Articles