各位大神能教我怎么使用jqurey给servlet发请求并且把取到的一个对象数组返回给客户端啊

润泽-安 2012-04-19 10:35:55
<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<script src="js/jquery-1.4.21.min.js" type="text/javascript">
</script>



<script >
function abid(){
alert("你大爷");
var rt=document.getElementById("rtl");
var pbid = "rt="+rt.value;
$.ajax{
type:"post",
url:"sexp2",
data:pbid,
susscess:function(list2,json){
${"#xuanze"}.html(pe);
}
}
// alert(rt.value);
//var op=rt.length;
//for(var i=1;i<op;i++){
//if(rt.options(i).selected)

// alert(rtl.options(i).selected.value);
// }
}
</script>

</head>
<body >
<div id="zhuanjia">
<select id="rtl">
<option value="0">
--请选择类别--
</option>
<c:forEach items="${list}" var="adp">
<option value="${adp.bid}">
${adp.bidname}
</option>
</c:forEach>
</select>
<input onclick="abid()" type="button" value="弹出下拉列表的值" >
</div>

<div id="xuanze">
<font color="#FF0033" size="4">候选专家</font>
<table id="zhuanjia1" class="tb">
<thead bgcolor="#DFDFDF">
<td>
选择
</td>
<td>
专家编号
</td>
<td>
名字
</td>
<td>
操作
</td>
</thead>
<tr>
<td>
<input type="checkbox" />
</td>
<td></td>
<td></td>
<td>
<input type="button" value="详细">
</tr>
</table>
<input type="button" value="确定" onclick="queding()">
</div>


<div id="zhuanjiaxinxi" class="div2">
专家姓名
<input class="tex" type="text" readonly="true" />
照片
<img src="">
</br>
性别
<input class="tex" type="text" />
</br>
年龄
<input class="tex" type="text" />
</br>
专业
<input class="tex" type="text" />
</br>
电子邮件
<input class="tex" type="text" />
</br>
学位
<input class="tex" type="text" />
</br>
</div>

<div id="zhuanjia2">
<font color="#FF0033" size="4">已选专家</font>
<table id="zhuanjia1" class="tb">
<thead bgcolor="#DFDFDF">
<td>
选择
</td>
<td>
专家编号
</td>
<td>
名字
</td>
<td>
操作
</td>
</thead>
<tr>
<td></td>
<td></td>
<td></td>
<td>
<input type="button" value="删除">
</tr>
</table>
<input type="button" value="提交" onclick="submit1()">
</div>
</body>
</html>
...全文
138 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
    <script type="text/javascript">
$(document).ready(function () {
$("#按钮id").click(function()
{

$.post("<%=basePath%>servlet路径", 提交参数, function(result)
{

});
});

});
</script>
  • 打赏
  • 举报
回复
	<script type="text/javascript">
$(document).ready(function () {
$("#saveDocument").click(function()
{
if(validateDocument($("#documentCreate")[0])==false){
return;
}

$.post("<%=basePath%>secure/document/createSaveDocument", $("#documentCreate").serialize(), function(result)
{

});
});

});
</script>
result是你从后台取到的数据

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧