在使用 jquery ajax json jsp 处理数据时出错
没有成功答应出page的值,请问该怎么修改才能让程序正确执行。------------------------index.jsp页面
<script src="JS/JQuery.js" type="text/javascript"></script>
<script type="text/javascript">
function _data(){
$.ajax({
url: "index2.jsp",
data: {page:2},
dataType: "json",
contentType: "application/json;charset=utf-8",
type: "get",
success: function (data,textStatus){
alert(data.page);
}
});
}
</script>
</head>
<body>
<input type="button" id="ajaxs" value="Ajax" onclick="_data()"/>
</body>
------------------------inde2.jsp页面
<body>
<%
response.setCharacterEncoding("gb2312");
request.setCharacterEncoding("gb2312");
String page2=request.getParameter("page");
response.setContentType("application/json;charset=utf-8");
PrintWriter out2= response.getWriter();
JSONArray jsonArray = new JSONArray();
JSONObject json = new JSONObject();
json.put("page",page2);
out2.write(json.toString());
%>
</body>