按下按钮后,我收到以下警告并且表单重复。代码中有错误吗?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1254" />
<script src="jquery-ui-1.10.0.custom/jquery-1.9.1.min.js" type="text/javascript"></script>
<title>jquery AJAX</title>
<script language="javascript">
$(document).ready(function(){
var name = $("#name").val();
var sname = $("#sname").val();
var email = $("#email").val();
$("#b1").click(function(){
$.ajax({
type :"POST",
URL :"save.php",
data :"name="+name+"&sname="+sname+"&email="+email,
dataType:"text",
success :function (data, textStatus, jqXHR) {
if (data == 'success'){
$("#res").html("sonuc :"+data);
}else{
$("#res").html(data +":"+textStatus+":"+jqXHR);
}
}
});
});
});
</script>
</head>
<body>
<input type="text" id="name"/><br />
<input type="text" id="sname"/><br />
<input type="text" id="email"/><br />
<button id="b1">send</button>
<div id="res"></div>
</body>
</html>