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
Post a Comment