日期:2014-05-16 浏览次数:20797 次
前段时间为了一个参数折腾一天,也不知为什么会这样,发现只要data参数里面带phone的关键字就传不过去,不知是咋回事,很是不爽,在此一提,希望有高人指点一下。
测试页:
<!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=utf-8" />
<title>测试</title>
<script src="/newindex/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript">
function aa(){
$.ajax({
type:"GET",
url:"Chuli.jsp",
data:"phone=15900233744&username=黑蛋&userimg=1&usersex=男&ttt="+Math.random(),
error:function(){
alert("服务器繁忙,请稍候在试!");
},
success:function(msg){
var return_info=msg.replace(/(^\s*)|(\s*$)/g, "");
if(return_info=="hel"){
alert("成功");
}
}
});
}
</script>
</head>
<body>
<input type="button" onclick="aa()" value="测试" />
</body>
</html>
Chuli.jsp页面:
<%@ page language="java" import="java.util.*,java.io.PrintWriter" pageEncoding="UTF-8"%>
<%
PrintWriter out2 = response.getWriter();
String phone = request.getParameter("phone");
String username = request.getParameter("username");
String userimg = request.getParameter("userimg");
String usersex = request.getParameter("usersex");
System.out.println("uname"+username);
String str="hel";
out2.print(str);
out2.flush();
out2.close();
%>
只要data参数里带phone就报alert("服务器繁忙,请稍候在试!");不知是怎么回事,求高人指点!!!!!!!!!