Javascript 表单不使用jquery和post发送值
这是我的代码,当我点击按钮时没有正确地提醒表单,我不知道我是否因为匆忙而做错了什么Javascript 表单不使用jquery和post发送值,javascript,php,jquery,html,Javascript,Php,Jquery,Html,这是我的代码,当我点击按钮时没有正确地提醒表单,我不知道我是否因为匆忙而做错了什么 <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title></title> <script src="http://code.jquery.com/jquery-
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<link rel="stylesheet" href="form.css" />
<script>
$(document).ready(function(){
$("#button").click(function(){
var form = $("#form").serialize();
alert(form);
$.post("action.php", form, function(data){
$("#response").html(data);
});
});
});
</script>
</head>
<body>
<form id="form">
<table>
<tr colspan="2" style="text-align: center;">
<td><b>Formulario</b></td>
</tr>
<tr>
<td>Código Alumno:</td>
<td><input type="text" id="alumno" /></td>
</tr>
<tr>
<td>Códido curso:</td>
<td><input type="text" id="curso"/></td>
</tr>
<tr>
<td>Código profesor:</td>
<td><input type="text" id="profesor"/></td>
</tr>
<tr>
<td>Correo profesor:</td>
<td><input type="text" id="correo"/></td>
</tr>
<tr>
<td>Descripción:</td>
<td><textarea rows="10" cols="30"></textarea></td>
</tr>
<tr>
<td colspan="2"><input type="button" id="button" value="Enviar"/></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</table>
</form>
<div id="response"></div>
</body>
</html>
请您应该像这样向输入控件添加name属性
<input type="text" id="correo" name="correo" /></td>
然后您的action.php将获得所需的参数。您正在做一些事情,因为您很匆忙,这不是产生错误的页面
<input type="text" id="correo" name="correo" /></td>