jquery 序列化表單進行提交筆記

//php代碼javascript

<?php

print_r($_POST);
?>php



html代碼:html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>serlize序列化表單傳值</title>
<script type="text/javascript" src="../../jquery-1.3.1.js"></script>
<script>
  $(function(){
	$('input[type=button]').click(function(){
		var date=$('#ff').serialize();
		//alert(date);return false;
		$.ajax({
		  url:'server.php',
		  data:date,
		  type:'post',
		  success:function(data){
		  	alert(data);
		  }
		});
		
	});
})

</script>
</head>
<body>
<div id="content">
<form action="server.php" method="post" accept-charset="utf-8" id="ff">
	<input type="text" name="username" /><br/>
	<input type="text" name="email" /><br/>
	<input type="text" name="password" /><br/>
	<input type="button" value="Continue" /><br/>
</form>	
</div>
</body>
</html>
相關文章
相關標籤/搜索