易截截图软件、单文件、免安装、纯绿色、仅160KB

ajax请求不返回html代码


ajax请求不返回html代码的三种方式
ajax请求代码:
function ajaxSend() {
$.ajax({
url: “Test_Ajax.aspx”,
type: “post”,
data: { name: “ajax” },//如果请求的自身页面,为了在后台判断是不是ajax请求
error: function(xhr, textStatus, errorThown) {
alert(errorThown);
},
success: function(data) {
alert(data);
}
});
}
1、把.aspx页面的html代码删除,删除后代码如下(ajax请求的不是自身页面)
.aspx页面代码
<%@ Page Language=”C#” AutoEventWireup=”true” CodeBehind=”AjaxReceive.aspx.cs” Inherits=”testJqueryUI.ajax.AjaxReceive” %>
.aspx.cs页面代码如下
protected void Page_Load(object sender, EventArgs e)
{
Response.Write(“love life”);
}
2.通过clear和end方法实现
.aspx.cs代码如下
string name = Request["name"];
//如果请求的是自身页面则需要这一步,判断是不是ajax请求
if (!String.IsNullOrEmpty(name))
{
Response.Clear();
Response.Write(“hello the world”);
Response.End();
}
3、通过实现IHttpModul实现
httpmodul代码如下
public class AjaxModul : IHttpModule
{
#region IHttpModule Members
public void Dispose()
{
//throw new NotImplementedException();
}
public void Init(HttpApplication context)
{
context.ReleaseRequestState += AjaxFilter;
}
private void AjaxFilter(object sender, EventArgs e)
{
HttpRequest request = HttpContext.Current.Request;
HttpResponse response = HttpContext.Current.Response;
if (!string.IsNullOrEmpty(request["name"]))
{
HttpResponse reponse1 = HttpContext.Current.Response;
reponse1.Filter = new AjaxResponseFilter(reponse1.Filter);
}
}
#endregion
}
AjaxResponseFilter.cs代码如下
public class AjaxResponseFilter : Stream
{
private readonly StringBuilder html;
private Stream response;
/// <summary>
/// 所有要往页面输出的内容保存在html中
/// </summary>
/// <param name=”buffer”></param>
/// <param name=”offset”></param>
/// <param name=”coun


相关文档:

HTML CSS标签

<html >
<body style="margin:0;overflow:hidden">
    <div>
     <table style="width:100%;height:100%">
         <!--<tr>
           & ......

COM的HTML控件

http://www.experts-exchange.com/Programming/Languages/C/Q_24038236.html
/* CWebPage.c

This is a Win32 C application (ie, no MFC, WTL, nor even any C++ -- just plain C) that demonstrates
how to embed a browser "control" (actually, an OLE object) in your own window (in order to display a
web p ......

html读书笔记

1.什么是 HTML 文件?
HTML 指超文本标签语言。
HTML 文件是包含一些标签的文本文件。
这些标签告诉 WEB 浏览器如何显示页面。
HTML 文件必须使用 htm 或者 html 作为文件扩展名。
HTML 文件可以通过简单的文本编辑器来创建。
2.HTML 元素
HTML 文档是由 HTML 元素构成的文本文件。
HTML 元素是通过使用 HTML ......

Struts2 Jquery Json 实现AJax表单验证

弄了一整天了,刚开始学习Jquery,很多东西还不熟,看看视频,查查资料,终于成功的集成Struts2+Jquery+Json
直接上图:用户名输入xxx,焦点丢失,提示”用户已存在“,否则提示“可以注册“,密码同样如此,
首先需要导包:如下除了struts2必须的包外,还有json包以及涉及的commons的几个包.
此外要下 ......

Silverlight 4 的Host HTML功能介绍

Silverlight 4新功能: Host HTML Content.
这个新功能挺不错的,可惜的是它只能是你把SilverLight应用程序安装到客户端才能使用,不明白为什么SilverLight Toolkit团队不让它能够在浏览器中也可以用。
看了段视频,它主要是讲了三个应用,其它还有很多使用这个功能的方法你可以试着在下面给我留言,大家一起学习。
  ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号