惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
O
OpenAI News
GbyAI
GbyAI
L
LINUX DO - 最新话题
A
Arctic Wolf
T
Tor Project blog
G
GRAHAM CLULEY
I
InfoQ
博客园_首页
IT之家
IT之家
The Register - Security
The Register - Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
K
Kaspersky official blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
U
Unit 42
PCI Perspectives
PCI Perspectives
量子位
P
Palo Alto Networks Blog
S
Securelist
T
Troy Hunt's Blog
博客园 - 【当耐特】
Recorded Future
Recorded Future
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
博客园 - 聂微东
罗磊的独立博客
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
NISL@THU
NISL@THU
C
Cisco Blogs
T
Threatpost
有赞技术团队
有赞技术团队
Forbes - Security
Forbes - Security
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
T
The Exploit Database - CXSecurity.com
Cloudbric
Cloudbric
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
C
Cyber Attacks, Cyber Crime and Cyber Security

博客园 - 廖勇军

关于c++的头文件依赖 增强资源管理器右键功能,含源代码 VC中结构体的内存布局 进程间共享句柄三种方式 SocanCode连接Oracle的方法 SocanCode7之模板编写 不用再纠结反射影响效率了 javascript总结 IIS7.0中使用MVC3,静态页正常,其它404 ashx的使用 一起来灭掉IE6! iis express感觉还不错 关于sqlite使用entity framework的布署问题 - 廖勇军 - 博客园 负margin实现div的左右排版 错误1067进程意外终止 关于省市联动的问题想法 javac编译多个带package文件 远程服务器返回了错误 NOTFOUND Java程序放到Linux上出现的问题
原来Jquery.load的方法可以一直load下去
廖勇军 · 2011-03-25 · via 博客园 - 廖勇军

使用jQuery.load方法加载一个网页,那么这个网页内部的js代码是否能够执行呢,答案是肯定的,这就相当于把load的内容与主页面进行了合并一样,只要不冲突(例如id不能一样),我写了一个例子,利用页面参数控制内部的元素id,互相加载自己。这是一个jsp页面,代码如下: 

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
    
String path = request.getContextPath();
    
String basePath = request.getScheme() + "://"
            
+ request.getServerName() + ":" + request.getServerPort()
            
+ path + "/";
    
int i = Integer.parseInt(request.getParameter("i")==null?"0":request.getParameter("i"));
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    
<head>
        
<base href="<%=basePath%>"><title>用户登录</title>
        
<meta http-equiv="pragma" content="no-cache">
        
<meta http-equiv="cache-control" content="no-cache">
        
<meta http-equiv="expires" content="0">
        
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        
<meta http-equiv="description" content="This is my page">
        
<script type="text/javascript" src="<%=path%>/Scripts/jquery-1.5.1.js"></script>
        
<script type="text/javascript">
        $(document).ready(
function(){
            $(
"#h<%= i %>").click(function(){
                $(
"#d<%= i %>").load("<%=basePath%>index.jsp",{i:<%=i+1%>});
            });
        });
        
</script>
    
</head><body>
        this is index.jsp?i=
<%= i %>
        
<input type="button" value="get<%= i+1 %>" id="h<%= i %>">
        
<br>
        
<div id="d<%= i %>" style="border:1px; border-style: solid; margin: 5px;">load index.jsp?i=<%= i+1 %> here!</div>
        
    
</body>
</html>

运行后如图所示,可以一直点下去:

但是,如果你只取的是页面的一部分,例如将按钮的点击代码改成:

$("#d<%= i %>").load("<%=basePath%>Login.action input",{i:<%=i+1%>});

那么,加载的就只是一个按钮了,而不是整个页面。如图: