javascript - jquery - .submit() function not working inside ajax() function -
I'm new to Ajax. The requirement is quite simple when the submit button is pressed, javascript makes an asynchronous request, which will validate different side user input. If the input is ok, then the form standard will submit, otherwise there will be an error message.
So, this is my form:
& lt; Form id = "form" action = "dosomething.jsp" method = "post" & gt; & Lt; Input type = "text" name = "name" & gt; & Lt; Input type = "text" name = "email" & gt; & Lt; Input id = "submit" type = "submit" value = "go" & gt; & Lt; / Form & gt; This is my javascript:
$ (document) .ready (function () {$ ("# form"). Submit (function (event )} {Event.preventDefault (); var form = $ (this); var button = $ ("# submit") button. Reuters ("disabled", "disabled"); $ .aex ({url: "valid Search: "post", data: form.serialize (), success: function (msg) {if (msg == "") {form.unbind ("submit"); form.submit ();} Else {alert (msg); button .removeAttr ("disabled");}}});});}); The code works fine, except for a form.submit (); is not working I will try it out of the AJAX () function, it will be deposited, so I think there is a problem about the scope, but I can not fix it. me
Comments
Post a Comment