サーバーにデータを送信する

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="ja">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Sample</title>
<link rel="stylesheet" href="css/main.css" type="text/css" media="all">
<script type="text/javascript" src="js/prototype.js" charset="shift_jis"></script>
<script type="text/javascript"><!--
Event.observe(window, "load", function(){
$("registButton").onclick = function(){
new Ajax.Request("./regist.cgi", {
method : "post",
parameters: "cache=" + (new Date()).getTime(),
postBody : Form.serialize("userData"),
onSuccess : function(httpObj){
$("registStatus").innerHTML = httpObj.responseText;
}
});
$("registStatus").innerHTML = "登録中です...";
}
}, false);
// --></script>
</head>
<body>
<h1>サーバーにデータを送信する</h1>
<form id="userData">
名前:<input type="text" value="安室 玲" name="userName"><br>
年齢:<input type="text" value="15" name="userAge"><br>
種類:<input type="text" value="頑打武" name="userType"><br>
<input type="button" value="民明書房に登録" id="registButton">
</form>
<div id="registStatus"></div>
</body>
</html>
サンプルを実行
[戻る]
prototype.jsパーフェクトリファレンス説明などは本書を参考にしてください。