ajax请求到后台数据,前台不用拼接字符串append追加HTML标签,一样显示到页面 (使用空模板)
来源:互联网 发布:淘宝商品拍照技巧 编辑:程序博客网 时间:2024/05/21 19:33
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!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 type="text/javascript" src=\'#\'" /js/jquery-1.11.1.min.js"></script>
<style>
</style>
<script>
$(document).ready(function() {
//搜索按钮(全部搜索和按条件搜索)
$("#searchBtn").click(function(){
var itemname = $("#itemname").val();
var year = $("#year option :selected ").val();
//当输入框为空,年份没选择,就为搜索全部数据
if(itemname =="" && year == undefined){
$.get("<%=request.getContextPath()%>/searchAll",
function(data){
$.each(data.tasklist ,function(i,obj){
/* 获取数据,添加给模板表格 */
$("#temp_table #temp_tr #id").text(obj.id);
$("#temp_table #temp_tr #name").text(obj.name);
$("#temp_table #temp_tr #type").text(obj.type);
$("#temp_table #temp_tr #cost").text(obj.cost);
$("#temp_table #temp_tr #state").text(obj.state);
$("#temp_table #temp_tr #date").text(obj.date);
/*复制模板表格,并插入到指定位置,参数true,表示CSS和事件也克隆 */
$("#temp_table #temp_tr").clone(true).insertAfter("#is_header");
});
});
}
});
});
</script>
</head>
<body>
<div id="temp" style="display: none;">
<table id="temp_table">
<tr id="temp_tr">
<td id="id" width="5%" height="25" align="center" bgcolor="#EFFBFE">aa</td>
<td id="name" align="center" bgcolor="#EFFBFE">bb</td>
<td id="type" colspan="2" align="center" bgcolor="#EFFBFE">cc</td>
<td id="cost" align="center" bgcolor="#EFFBFE">dd</td>
<td id="date" align="center" bgcolor="#EFFBFE">ff</td>
<td id="state" align="center" bgcolor="#EFFBFE">ee</td>
<td align="left" bgcolor="#EFFBFE">
<div align="left" style="padding-left: 5px">
<div align="center">
<input name="edit" type="button" value="编辑" />
<input name="delete" type="button" value="删除"/>
</div>
</div>
</td>
</tr>
</table>
</div>
<!-- 以下是显示到页面的内容-->
<table width="99%" height="25" border="0" align="center"
cellpadding="0" cellspacing="0" style="margin-bottom: 4px;">
<tr>
<td width="17" background="images/bj4.gif"><img
src="Picture/r.gif" width="16" height="16" /></td>
<td width="466" background="images/bj4.gif">张宇(学院申报者):你好!欢迎光临,您上次登录时间是:2015-09-20
23:15:15</td>
<td width="162" align="center" background="images/bj4.gif"></td>
</tr>
</table>
<table width="99%" border="0" align="center" cellpadding="0"
cellspacing="0">
<tr>
<td width="1%" align="left" background="images/b2.jpg"><img
src="Picture/b1.jpg" width="10" height="26" /></td>
<td width="68%" background="images/b2.jpg"><table width="124"
border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td width="20" align="left"><img src="Picture/tz.gif"
width="10" height="16" /></td>
<td width="104" align="left" class="biao">项目搜索</td>
</tr>
</table></td>
<td width="31%" align="right" background="images/b2.jpg"><img
src="Picture/b3.jpg" width="9" height="26" /></td>
</tr>
</table>
<table width="99%" border="0" align="center" cellpadding="3"
cellspacing="1" bgcolor="#AEDEF4">
<tr>
<td align="center" bgcolor="#E2F7FE">
<form id="form1" name="form1" method="post"
action="<%=path%>/searchByYear">
<table width="50%" border="0" cellspacing="1" cellpadding="3">
<tr>
<td width="10%" height="25" align="center">项目名称:</td>
<td width="14%" align="left"><label> <input
name="itemname" type="text" id="itemname" size="20" />
</label></td>
<td width="6%" align="center">年份:</td>
<td width="14%" align="left"><select name="year" id="year">
<option value="">全部</option>
<option value='2009'>2009</option>
<option value='2010'>2010</option>
<option value='2011'>2011</option>
<option value='2012'>2012</option>
<option value='2013'>2013</option>
<option value='2008'>2008</option>
<option value='2014'>2014</option>
<option value='2015'>2015</option>
<option value='2016'>2016</option>
<option value='2017'>2017</option>
</select></td>
<td width="8%"><input type="button" id="searchBtn"
name="searchBtn" value="搜索" /></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<table width="50%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="5"></td>
</tr>
</table>
<table width="99%" border="0" align="center" cellpadding="0"
cellspacing="0">
<tr>
<td width="1%" align="left" background="images/b2.jpg"><img
src="Picture/b1.jpg" width="10" height="26" /></td>
<td width="68%" background="images/b2.jpg"><table width="124"
border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td width="20" align="left"><img src="Picture/tz.gif"
width="10" height="16" /></td>
<td width="104" align="left" class="biao">项目列表</td>
</tr>
</table></td>
<td width="31%" align="right" background="images/b2.jpg"><img
src="Picture/b3.jpg" width="9" height="26" /></td>
</tr>
</table>
<!-- 这里是获取后台数据,并画出显示表格 -->
<table id="is_table" width="99%" border="0" align="center"
cellpadding="3" cellspacing="1" bgcolor="#AEDEF4"
style="border: 1px solid #AEDEF4">
<tr id="is_header">
<td width="5%" height="25" align="center" bgcolor="#EFFBFE">ID</td>
<td align="center" bgcolor="#EFFBFE">项目名称</td>
<td colspan="2" align="center" bgcolor="#EFFBFE">项目类型</td>
<td align="center" bgcolor="#EFFBFE">申请经费</td>
<td align="center" bgcolor="#EFFBFE">提交时间</td>
<td align="center" bgcolor="#EFFBFE">状态</td>
<td align="center" bgcolor="#EFFBFE">管理操作</td>
<td height="25" bgcolor="#FFFFFF"> </td>
<td colspan="6" bgcolor="#FFFFFF"><span class='pagelink'>首页</span>
<span class='pagelink'>上一页</span> <span class='pagelink'>下一页</span>
<span class='pagelink'>尾页</span> 转到第 <input
id='jumpSelect' type='text' size='2' value='1' />页</td>
<td bgcolor="#FFFFFF">
</td>
</tr>
</table>
</body>
</html>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!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 type="text/javascript" src=\'#\'" /js/jquery-1.11.1.min.js"></script>
<style>
</style>
<script>
$(document).ready(function() {
//搜索按钮(全部搜索和按条件搜索)
$("#searchBtn").click(function(){
var itemname = $("#itemname").val();
var year = $("#year option :selected ").val();
//当输入框为空,年份没选择,就为搜索全部数据
if(itemname =="" && year == undefined){
$.get("<%=request.getContextPath()%>/searchAll",
function(data){
$.each(data.tasklist ,function(i,obj){
/* 获取数据,添加给模板表格 */
$("#temp_table #temp_tr #id").text(obj.id);
$("#temp_table #temp_tr #name").text(obj.name);
$("#temp_table #temp_tr #type").text(obj.type);
$("#temp_table #temp_tr #cost").text(obj.cost);
$("#temp_table #temp_tr #state").text(obj.state);
$("#temp_table #temp_tr #date").text(obj.date);
/*复制模板表格,并插入到指定位置,参数true,表示CSS和事件也克隆 */
$("#temp_table #temp_tr").clone(true).insertAfter("#is_header");
});
});
}
});
});
</script>
</head>
<body>
<div id="temp" style="display: none;">
<table id="temp_table">
<tr id="temp_tr">
<td id="id" width="5%" height="25" align="center" bgcolor="#EFFBFE">aa</td>
<td id="name" align="center" bgcolor="#EFFBFE">bb</td>
<td id="type" colspan="2" align="center" bgcolor="#EFFBFE">cc</td>
<td id="cost" align="center" bgcolor="#EFFBFE">dd</td>
<td id="date" align="center" bgcolor="#EFFBFE">ff</td>
<td id="state" align="center" bgcolor="#EFFBFE">ee</td>
<td align="left" bgcolor="#EFFBFE">
<div align="left" style="padding-left: 5px">
<div align="center">
<input name="edit" type="button" value="编辑" />
<input name="delete" type="button" value="删除"/>
</div>
</div>
</td>
</tr>
</table>
</div>
<!-- 以下是显示到页面的内容-->
<table width="99%" height="25" border="0" align="center"
cellpadding="0" cellspacing="0" style="margin-bottom: 4px;">
<tr>
<td width="17" background="images/bj4.gif"><img
src="Picture/r.gif" width="16" height="16" /></td>
<td width="466" background="images/bj4.gif">张宇(学院申报者):你好!欢迎光临,您上次登录时间是:2015-09-20
23:15:15</td>
<td width="162" align="center" background="images/bj4.gif"></td>
</tr>
</table>
<table width="99%" border="0" align="center" cellpadding="0"
cellspacing="0">
<tr>
<td width="1%" align="left" background="images/b2.jpg"><img
src="Picture/b1.jpg" width="10" height="26" /></td>
<td width="68%" background="images/b2.jpg"><table width="124"
border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td width="20" align="left"><img src="Picture/tz.gif"
width="10" height="16" /></td>
<td width="104" align="left" class="biao">项目搜索</td>
</tr>
</table></td>
<td width="31%" align="right" background="images/b2.jpg"><img
src="Picture/b3.jpg" width="9" height="26" /></td>
</tr>
</table>
<table width="99%" border="0" align="center" cellpadding="3"
cellspacing="1" bgcolor="#AEDEF4">
<tr>
<td align="center" bgcolor="#E2F7FE">
<form id="form1" name="form1" method="post"
action="<%=path%>/searchByYear">
<table width="50%" border="0" cellspacing="1" cellpadding="3">
<tr>
<td width="10%" height="25" align="center">项目名称:</td>
<td width="14%" align="left"><label> <input
name="itemname" type="text" id="itemname" size="20" />
</label></td>
<td width="6%" align="center">年份:</td>
<td width="14%" align="left"><select name="year" id="year">
<option value="">全部</option>
<option value='2009'>2009</option>
<option value='2010'>2010</option>
<option value='2011'>2011</option>
<option value='2012'>2012</option>
<option value='2013'>2013</option>
<option value='2008'>2008</option>
<option value='2014'>2014</option>
<option value='2015'>2015</option>
<option value='2016'>2016</option>
<option value='2017'>2017</option>
</select></td>
<td width="8%"><input type="button" id="searchBtn"
name="searchBtn" value="搜索" /></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<table width="50%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="5"></td>
</tr>
</table>
<table width="99%" border="0" align="center" cellpadding="0"
cellspacing="0">
<tr>
<td width="1%" align="left" background="images/b2.jpg"><img
src="Picture/b1.jpg" width="10" height="26" /></td>
<td width="68%" background="images/b2.jpg"><table width="124"
border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td width="20" align="left"><img src="Picture/tz.gif"
width="10" height="16" /></td>
<td width="104" align="left" class="biao">项目列表</td>
</tr>
</table></td>
<td width="31%" align="right" background="images/b2.jpg"><img
src="Picture/b3.jpg" width="9" height="26" /></td>
</tr>
</table>
<!-- 这里是获取后台数据,并画出显示表格 -->
<table id="is_table" width="99%" border="0" align="center"
cellpadding="3" cellspacing="1" bgcolor="#AEDEF4"
style="border: 1px solid #AEDEF4">
<tr id="is_header">
<td width="5%" height="25" align="center" bgcolor="#EFFBFE">ID</td>
<td align="center" bgcolor="#EFFBFE">项目名称</td>
<td colspan="2" align="center" bgcolor="#EFFBFE">项目类型</td>
<td align="center" bgcolor="#EFFBFE">申请经费</td>
<td align="center" bgcolor="#EFFBFE">提交时间</td>
<td align="center" bgcolor="#EFFBFE">状态</td>
<td align="center" bgcolor="#EFFBFE">管理操作</td>
</tr>
<!-- 克隆的模板表格,粘贴到这里 -->
<td height="25" bgcolor="#FFFFFF"> </td>
<td colspan="6" bgcolor="#FFFFFF"><span class='pagelink'>首页</span>
<span class='pagelink'>上一页</span> <span class='pagelink'>下一页</span>
<span class='pagelink'>尾页</span> 转到第 <input
id='jumpSelect' type='text' size='2' value='1' />页</td>
<td bgcolor="#FFFFFF">
</td>
</tr>
</table>
</body>
</html>
阅读全文
1 0
- ajax请求到后台数据,前台不用拼接字符串append追加HTML标签,一样显示到页面 (使用空模板)
- ajax请求得到后台数据,前台页面,使用table模板然后clone,显示表格,,不用append拼接 “字符串和HTML表格标签”
- 后台拼接HTML显示到前台
- 后台html标签到前台显示错误问题
- jquery 使用ajax请求数据显示到页面表格中
- 使用ajax将后台数据输出到前台,实现页面动态化
- 前端通过Ajax请求从后台返回数据到页面显示,实现分页功能
- Ajax 异步或取后台数据json显示到页面
- mvc-ajax(从后台取数据显示到页面上)
- 运用struts2 进行html代码从后台到前台页面的转义显示
- 前台发送 ajax 请求到后台传递数组参数
- C#后台拼接参数,前台显示数据
- 将后台数据显示到前台页面的方法springmvc+hibernate+spring
- 使用easyUI的treegrid的时候,出现后台返回数据为空时,treegrid加载了前面请求到的数据到页面上的问题
- 使用echart从后台获取数据动态显示到页面
- 前台用的是ajax请求,后台json字符串拼接方式
- 若请求数据大而且处理时间长,为了防止页面load timeout,可以先render页面,再异步发ajax请求,将数据append到页面。
- ajax前台中文数据到后台处理接收时乱码
- Swift 自定义相机扫描身份证信息
- HTML初学
- Java如何从HttpServletRequest中读取HTTP请求的body
- Weblogic Jms简单使用
- Kotlin开发工具IntelliJ的下载和创建项目
- ajax请求到后台数据,前台不用拼接字符串append追加HTML标签,一样显示到页面 (使用空模板)
- java集合浅析
- Activity生命周期
- Windows-caffe+vs2013+MATLAB2016b接口配置+调试
- Android Kotlin遇到的坑
- Vue-cli开发SPA应用(适用初学者)
- ntp配置时间同步服务器
- DataGrid中出现在AddNew或EditItem事务过程不允许Deferrefresh报错
- 系统移植相关网址