javascriptを使用してajax経由でフォームを送信するにはどうすればよいですか。これが私のコードです:
<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>
ここに私の隠しフォームがあります
<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>
送信をクリックすると、新しいコメント(テキストエリアから)とともにajaxコードを介してすぐに送信されます。
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 i already know; }
}
これは機能しますか?