javascript - POST array with jQuery and Ajax -


i have form multiple fields, whereby fields can added.

the form follows:

<form id="myform" action="myfile.php" > <input . . >   <select>. . . </select>  </form> 

myfile.php has following code:

foreach ($_post $key => $value) {  echo $key." takes <b>".$value."</b> value";   } 

this simple code processes entries of form regardless how many.

now, want is:

when click on submit button, instead of sending form's content script, array , pass ajax without having write every single key , value manually.

i hope makes sense

i think looking serialize()

jquery(function ($) {     //submit handler     $('#myform').submit(function (e) {         //prevent default submit         e.preventdefault();          $.ajax({             url: $(this).attr('action'),             type: 'post',             data: $(this).serialize(),             ....         })     }); }) 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -