利用JQuery的load函数动态加载页面 以及jQuery动态加载页面和请求所返回的数据
来源:互联网 发布:51单片机延时1s的程序 编辑:程序博客网 时间:2024/06/12 23:10
利用JQuery的load函数动态加载页面
我们来做个例子:
做一个上下(左右)结构的页面,其中下左部分放2个以前我们做过的div按钮,下右部分则为动态加载内容。
按每个按钮,加载该按钮相应的网页内容到下右区域。
基本语法为:
$('#区域id').load('页面名称');
完整的网页代码如下:
<head runat="server">
<title>JQuery - Load</title>
<link rel="stylesheet" media="all" type="text/css" href="../CSS/myStyle.css" />
<script type="text/javascript" src="../JsLib/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="../JS/basicEffect.js"></script>
<style type="text/css">
#header {
margin-bottom: 1em;
padding-bottom: 1em;
border-bottom: 1px solid #eee;
}
.buttonListArea {
float: left;
width: 150px;
padding-right: 10px;
border-right: 1px solid #eee;
margin-right: 10px;
}
.buttonArea {
margin: 10px;
padding-bottom:20px;
}
#load_content {
float: left;
width: 550px;
text-align:center;
}
</style>
<script type="text/javascript">
$(document).ready(function() {
$('#btnLoad1.button').click(function() {
$('#load_content').load('loadContent1.htm');
});
$('#btnLoad2.button').click(function() {
$('#load_content').load('loadContent2.htm');
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="container">
<div id="header">
<h2>JQuery Load Example</h2>
</div>
<div class="buttonListArea">
<div class="buttonArea">
<div class="button" id="btnLoad1">Load 1</div>
</div>
<div class="buttonArea">
<div class="button" id="btnLoad2">Load 2</div>
</div>
</div>
<div id="load_content">
<h2>这是要被加载的区域</h2>
</div>
</div>
</form>
</body>
</html>
jQuery动态加载页面和请求所返回的数据
Default.aspx页面
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<script src="jquery-1.3.2.mini.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
function loadData()
{
//加载a.html到层
$("#divData").load("a.html");
//加载从data.ashx返回的数据到层
//$.get("data.ashx", function(data){$("#divData").html(data);});
//alert返回的数据
//$.get("data.ashx", function(data){alert("Data Loaded: " + data);});
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<a href="javascript:void(0);" onclick="loadData();">请求加载</a>
<span id="divData"></span>
</div>
</form>
</body>
</html>
data.ashx
<%@ WebHandler Language="C#" Class="data" %>
using System;
using System.Web;
public class data : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
}
public bool IsReusable {
get {
return false;
}
}
}
- 利用JQuery的load函数动态加载页面 以及jQuery动态加载页面和请求所返回的数据
- jQuery动态加载页面和请求所返回的数据
- jQuery动态加载页面和请求所返回的数据
- 利用Jquery的load函数实现页面的动态加载
- 【HTML/JS】利用JQuery的load函数动态加载其它页面的内容的实现代码
- [HTML/JS]利用JQuery的load函数动态加载其它页面的内容的实现代码代替Ifram
- jquery动态加载页面 load方法 注意事项
- 使用jquery的load方法设计动态加载,并解决被加载页面JavaScript失效问题
- jQuery的load方法设计动态加载及解决被加载页面js
- jquery的load函数实现页面的局部加载
- jQuery实现页面滚动时动态加载内容的方法
- 动态加载页面-使用jquery ajax
- Jquery load()加载GB2312页面时出现乱码的解决方法
- jQuery使用ajax的load()加载页面方法
- $.load加载动态页面ie失效,js失效的问题
- jquery中load()加载页面,刷新之后,加载的页面不显示的解决办法
- jquery的load方法为元素动态加载内容
- 异步请求动态加载页面
- mpeg4 vol header文件格式分析
- Ghost误操作之后--硬盘维护工具Diskgenius
- java包名的约定:PO VO TO BO DAO POJO
- $在COS的用法
- oracle job
- 利用JQuery的load函数动态加载页面 以及jQuery动态加载页面和请求所返回的数据
- 将截断字符串或二进制数据。语句已终止。
- 【转载】傅里叶变换和拉普拉斯变换的意义
- spring quartz
- AdroidManifest文件介绍
- FLUSH TABLES WITH READ LOCK 和 LOCK TABLES 之种种
- 疑难杂症: HP DL160G6 P410 下安装 Centos5.x x64
- CCNA实验二十三 单区域OSPF路由协议
- Java高手真经. 编程基础卷:Java核心编程技术:Java基础+核心库+图形+网络+高级特性