ajax
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script src="../jquery-1.8.3.js"></script>
</head>
<body>
<input type="button" value="发送ajax请求" 0/>
</body>
<script>
$("input").click(function(){
var url = "/jss/SendDateServlet";
var params = {"username":"jack", "password":"1234"};
/* $(this).load(url,params,function(data){
var jsondate=eval("("+data+")");
alert(jsondate.message);
}); */
/* $.get(url,params,function(data){
alert(data.message);
},"json"); */
/* $.post(url,params,function(data){
alert(data.message);
},"json"); */
$.ajax({
"url":url,
"date":params,//发送到服务器的数据
"type":"post",
"dataType":"json",//预期服务器返回的数据类型
"success":function(data){
alert(data.message);
},
"error":function(){
alert("出错了");
}
})
});
</script>
</html>