jquery - submit to multiple urls -


I have an html form with 2 fields: name and email form values ​​of 2 different urls from submit submit button Must have to submit. I have tried using jquery, serialize and post, but I'm not clear how to accomplish this. I can not use PHP in this example

  & lt ;; Doctype & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Script type = "text / javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" & gt; & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Form action = "" method = "post" name = "myform" id = "myform" & gt; & Lt; Input type = "text" value = "name" /> & Lt; Input type = "email" value = "email" /> & Lt; Input type = "button" id = "submit" value = "submit" /> & Lt; / Form & gt; & Lt; Script type = "text / javascript" & gt; $ (Document) .ready (function () {var url1 = "some-url.com"; var url2 = "some-other- url"; $ ("# submit"). (Function () {$. Post ("Url1", $ ("form # myform"). Serialize ()); $ .post ("url2", $ ('formmy # myform'). Serialize ());})}) & lt; / Script & gt; & Lt; / Body & gt;   

If you are using jquery:

 < Code> $ ("form"). Submit (function (event) {submitToURL1 (); submitToURL2 (); // some more warning (handler for ".submit ()."); Event.preventDefault (); // it does not get suit again}};   

submitToURL1 can be something like this:

  $ .post ("url1", data: $ ("form" ). Sort ());   

. Serialize () is a jquery function that takes the elements in one form and arranges them well You can send them as parameters in the post method. Example:

Go here more Kari:

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -