您好,登錄后才能下訂單哦!
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src="js/jquery-1.7.2.js"></script>
</head>
<body>
<form action="">
<select name="college" id="college" ></select>
</form>
<script>
$(function(){
$.get("jsonserver.jsp",function(data){
for(var i=0;i<data.length;i++)
$("#college").append(new Option(data[i].cname,data[i].value));
},"json");
})
</script>
</body>
</html>
jsonserver.jsp頁面
<%@ page language="java" contentType="text/html; charset=Utf-8"
pageEncoding="Utf-8"%>
<%
response.setHeader("Content-Type","text/xml");
response.setHeader("charset","utf-8");
String result ="[{\"value\":0,\"cname\":\"軟件學院\"},{\"value\":\"1\",\"cname\":\"計算機學院\"}]";
System.out.println(result);
out.print(result);
out.flush();
%>
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。