您的位置:首页 > Web前端 > JQuery

jQuery动态加载页面和请求所返回的数据

2009-05-23 15:19 639 查看
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;

}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐