JQuery Ajax获取返回html中指定的内容
来源:互联网 发布:吉利知豆d3 编辑:程序博客网 时间:2024/05/18 00:05
JQuery Ajax获取返回html中指定的内容
比如search功能,输入关键字,在数据库中查找对应的包含关键字的记录并显示在页面上,在一段Ajax请求之后,返回html text。。。
需要在返回的html中找到指定id的内容用来更新页面中的对应的html内容。。。
比如页面:
<div id="test">
<c:forEach var="solution" items="${mySolutions}">
<div class="solution">
<div class="span-1"><img src="${pageContext.request.contextPath}/resources/images/SolutionItem.png"></img></div>
<div class="span-18">
<div class="solutionName"><a href="view/${solution.id}">${solution.name}</a></div>
<div class="solutionDescription">${solution.shortDescription}</div>
</div>
<div class="span-2" id="tag_${solution.id}">
<div>
<a href="#" onclick="addTag('${solution.id}')">add</a>
more
</div>
<div><textarea style="width:75; height:25; overflow: auto;" rows="3" cols="5">111111111</textarea></div>
<div><textarea style="width:75; height:25; overflow: auto;" rows="3" cols="5">222222222</textarea></div>
<div><textarea style="width:75; height:25; overflow: auto;" rows="3" cols="5">333333333</textarea></div>
</div>
<div class="span-3 last"><img src="${pageContext.request.contextPath}/resources/images/sample-solution.jpg" class="solutionIcon" alt="Solution Icon"></img></div>
<div class="span-24 last solutionSplitter">
<hr/>
</div>
</div>
</c:forEach>
</div>
这个时候采用ajax局部更新:
如下:
$.ajax({type : "POST",url : 'test.jsp',dataType : "html",success: function(data) { alert( data ); // shows whole dom //alert( $(data).find('#test').html() ); // returns null $("#test").html($(data).find("#test").html()); },error : function() { alert("Sorry, The requested property could not be found.");}});
http://api.jquery.com/jQuery.ajax/#options
- JQuery Ajax获取返回html中指定的内容
- 打印html中指定内容
- Split 获取字符串中指定符号分割的字符内容
- C++替换文件中指定的内容
- 替换文本文件中指定的内容
- 删除Arraylist中指定内容的值
- js如何把html页面中指定的内容打印出来(下载下来)?
- js jquery 获取当前页面的url,获取frameset中指定的页面的url
- 使用JS获取Repeater中指定单元格的内容(单元格无控件)
- linux文件操作—获取文本中指定行的内容
- 获取xml中指定节点的值
- 获取URL中指定参数的值
- 获取git中指定的目录
- 获取github中指定tag的代码
- 获取js文件中指定的数据
- PHP获取数组中指定的一列
- jQuery的ajax返回html类型不能获取片段html代码
- 用Jquery获取Table指定行中指定列的数值
- UVa 10061 - How many zero's and how many digits ?
- 福建省委办公厅公务员考试头名因性格原因拒录-公务员-考试-拒录
- JavaScript验证页面
- 数据库设计中常见表结构的设计技巧
- 第八周上机任务(求还款金额)
- JQuery Ajax获取返回html中指定的内容
- oracle存储过程分页
- android 关于canvas.translate(x,y)
- win32 windows编程实现菜单栏
- 闲聊一句,目前连民工都不如
- 李长春抵达伊斯兰堡开始访问巴基斯坦-李长春-巴基斯坦-伊斯兰堡
- 数据库的查询优化技术
- Android用代码安装APK,不用选择“打包安装程序”
- 学习目录