Post php form jquery ajax -


i have form input field generated loop, ie

<form name="" method='post' action=''> <?php for($i=0;$i<10;$i++){  echo "<input type='text' name='data[]' class='data_cls' value='".$i."'>"; } ?> <input type='submit' id='btn' value='save'> 

i want submit form using jquery ajax.

$('.btn').click(function(){              var datstring = "how these values";              $.ajax({             url: "data_process.php",             type: "post",             data: datastring,             success: function(data) {                 alert('ok');             }         });       }); 

you can use .serialize() jquery method form data. this,

$('.btn').click(function(){              var datastring = $('#form_id').serialize();             //replace form_id id of form.              $.ajax({             url: "data_process.php",             type: "post",             data: datastring,             success: function(data) {                 alert('ok');             }         });       }); 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -