javascript - jQuery submit form AFTER validating it with ajax -


I have a difficult field for which verification must be passed on the server side. So I need to send a Ajax request with this field, to get the results to capture, if the result is valid for submission of form, other intelligent closure and showing the message.

How do I do this?

I've lost a bit of "big picture" with events and callbacks.

Even so far I have.

  $ ("form"). Submit (function (event) {event.preventDefault (); return check ();}); Function check () {var field = $ ('# myFiled'). Val (); If (! Field) {show.error ('Please enter the VIN number and retry'.); return false; } $ .getJSON ('MyURL', function) {if (! Data.valid) show. Panic ('invalid entry, please try again.');})}   

Update Please read the question. In case of successful verification, I will have to submit the routine form. Not by AJX

  $ ("form"). Submit (function (event) {Event.preventDefault (); check and submits ();}); Function checks and submits () {var field = $ ('# myFiled'). Val (); If (! Field) {show.error ('Please enter the VIN number and retry'.); } Else {$ .getJSON ('MyURL', function (data) {if (! Data.valid) {show.error ('invalid entry, please try again.');} Else {$ .post ('yourFromPostURL ', $ (' Form '). Serialize (), function (data) {// show some of success or failure.}}}}}}}}    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -