submit my form through ajax using javascript -
just wanted ask, how submit form through ajax using javascript. here's code:
<script> function show_edit(bugid,device) { document.getelementbyid('updateform').style.visibility='visible'; document.getelementbyid('u_bugid').value=bugid; document.getelementbyid('u_device').value=device; } function hide() { document.getelementbyid('updateform').style.visibility='hidden'; } </script> here's hidden form
<div id"update_form" > <form onsubmit="ajax_submit();"> <fieldset> <label for="maskset">maskset</label><input type='text' name='bugid' id='u_bugid' readonly > <label for="device">device</label><input type='text' name='device' id='u_device' readonly> <label for="reason">comments</label><textarea rows=10 cols=40 name='reason'></textarea> <input id="s_update" class='s_update' value="update data" type="submit" > </form> </fieldset> </div> can put way below, when click submit submit through ajax code new comment(from textarea):
function show_edit(bugid,device) { var maskset; document.getelementbyid('updateform').style.visibility='visible'; document.getelementbyid('u_bugid').value=bugid; document.getelementbyid('u_device').value=device; function ajax_submit() { //code in submitting ajax know; } } will work?
it seems want stop submition of code need add onsubmit="return ajax_submit()" html , make sure function return false.
function ajax_submit() { return false; } by looks of code benefit getting jquery in order select dom elements simplify life greatly.
on note make life hell of lot easier using jquery ajax. specially if read on jquery ajax functions .
$.post("test.php", { bugid: $('#u_bugid').val(), device: $('#u_device').val() } );
Comments
Post a Comment