javascript - I have form with same name -
I'm trying to use jQuery with the same name and defragment value in my HTML form, but then what When I submit the form my AJAX will not work and submit it to # . Why can anyone explain me?
My HTML Form:
& lt; Script src = "lib / jquery / jquery.1.9.0.min.js" & gt; & Lt; / Script & gt; & Lt; Form name = "form" action = "#" method = "POST" & gt; & Lt; Input name = "idnum" type = "hidden" value = "some size" 1 & lt; Button type = "submit" & gt; BTN1 & lt; / Button & gt; & Lt; / Form & gt; & Lt; Form name = "form" action = "#" method = "POST" & gt; & Lt; Input name = "idnum" type = "hidden" value = "somevaluehere2" & gt; & Lt; Button type = "submit" & gt; BTN2 & lt; / Button & gt; & Lt; / Form & gt; This is my Ajax:
$ (document) .ready (function () {$ ("form [name = form]"). (Function (e) {e.preventDefault () $ .exx ({type: "post", url: "ajax / post.fp"), data: $ (this). Serialize (), success: function ) {Alert (data)}});});}); Sorry for my English people
Form form
$ ("form [name = form]") to $ ("form ), Your selector does not match the form. [Name = form] ") .
You can prove this by comparing the warning ($ ("form [name = form]")); Warning ($ ("form [name = form]"). Length);
Note, however, that's why you should switch to using the class attribute instead (you can use the class selector ( form.Form ) instead.
Comments
Post a Comment