客户端:

  <script type="text/javascript">
window.onload = initPage; function initPage()
{
var btn = document.getElementById("btnOK");
btn.onclick = function ()
{
getDetails(this.title);//按钮单击发送请求
}
} function getDetails(obj)
{
request = createRequest(); //创建请求对象
if (request == null)
{
alert("没有请求对象!");
return;
}
var url = "DetailForm.aspx?title=" + escape(obj);//向何处发请求
request.open("GET", url, true); //请求方式
request.onreadystatechange = displayDetails;//函数引用,设置回调函数
request.send(null);//没有随请求发送额外东西
} function displayDetails()
{
if (request.readyState == 4)
{
if (request.status == 200)
{
document.getElementById("btnOK").value = request.responseText;
} }
}
function createRequest()
{
try
{
request = new XMLHttpRequest();
} catch (tryMS)
{
try
{
request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (otherMS)
{
try
{
request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed)
{
request = null;
}
}
}
return request;
} //完全看不到页面的刷新,却从服务器端拿回了数据!
</script>
<body>
<form id="form1" runat="server">
<div>
<input type="button" id="btnOK" value="Ok" title="确定" />
</div>
</form>
</body>

服务端:

 public partial class DetailForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string str = Request.QueryString["title"];
if (str != null && str != "")
{
Response.Write("new_" + str);
}
else
{
Response.Write("nothing");
}
Response.End();
}
}

深入浅出Ajax(一)的更多相关文章

  1. 深入浅出Ajax

    原文(我的GitHub):https://github.com/liangfengbo/frontend-ability/issues/1 学习大纲 理解Ajax的工作原理 Ajax核心-XMLHtt ...

  2. 深入浅出Ajax(五)

    function initPage() { alert("3+3");//3+3 alert(eval("3+3")); //6 //eval()函数可以解析. ...

  3. 深入浅出Ajax(四)

    function initPage() { btn.onmouseover = buttonOver; btn.onmouseover = buttonOut; } 如上,浏览器只会运行指定的最后一个 ...

  4. 深入浅出Ajax(三)

    <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> &l ...

  5. 深入浅出Ajax(二)

    <script type="text/javascript"> window.onload = initPage; function initPage() { var ...

  6. Java程序员从笨鸟到菜鸟全部博客目录

    本文来自:曹胜欢博客专栏.转载请注明出处:http://blog.csdn.net/csh624366188 大学上了一年半,接触java也一年半了,虽然中间也有其他东西的学习,但是还是以java为主 ...

  7. 大量Javascript/JQuery学习教程电子书合集

    [推荐分享]大量Javascript/JQuery学习教程电子书合集,送给有需要的人   不收藏是你的错^_^. 经证实,均可免费下载. 资源名称 资源大小   15天学会jQuery(完整版).pd ...

  8. [推荐分享]大量Javascript/JQuery学习教程电子书合集,送给有需要的人

    不收藏是你的错^_^. 经证实,均可免费下载. 资源名称 资源大小   15天学会jQuery(完整版).pdf 274.79 KB   21天学通JavaScript(第2版)-顾宁燕扫描版.pdf ...

  9. 【推荐分享】大量JavaScript/jQuery电子书籍教程pdf合集下载

    不收藏是你的错^_^. 经证实,均可免费下载. 资源名称 资源大小   15天学会jQuery(完整版).pdf 274.79 KB   21天学通JavaScript(第2版)-顾宁燕扫描版.pdf ...

随机推荐

  1. LeetCode OJ 100. Same Tree

    Given two binary trees, write a function to check if they are equal or not. Two binary trees are con ...

  2. CATransform3D的使用以及各个参数的含义

    1. 缩放 CABasicAnimation *theAnimation=[CABasicAnimation animationWithKeyPath:@"transform"]; ...

  3. document.createDocumentFragment 方法

    基本概念 document.createDocumentFragment 方法会创建一个 DocumentFragment 对象,该对象是一个存在于 DOM 树之外的 DOM 节点.它有一个非常有用的 ...

  4. 深入理解typedef

    首先请看看下面这两句:                  typedef int a[10];                  typedef void (*p)(void); 如果你能一眼就看出它 ...

  5. listview条目用状态选择器没反应

    button和imagebutton天生具有“可点击(click)”.“可按下(press)”的特性,radiobutton具有“可勾选(check)”的特性,但是listview的条目只有“可按下( ...

  6. Spring AOP面向切面编程的实现

    1.涉及到的几个概念 切面类.被切对象.切入点.切入时间.切入内容:(自己命的名,好理解点) 2.看配置文件 <?xml version="1.0" encoding=&qu ...

  7. CAPSPageMenu分页交互

    最近在开发过程中,我的前任在处理类似于新闻多板块的界面,在一个视图控制器里加载多个UITableView以显示不同类型的信息,并可通过头部按钮和左右滑动来切换不同的tableView这样的界面中,采取 ...

  8. java基础概念经典题目汇集

    1.下面是People和Child类的定义和构造方法,每个构造方法都输出编号.在执行new Child("mike")的时候都有哪些构造方法被顺序调用?请选择输出结果 ( ) cl ...

  9. java 数据结构 队列的实现

    java 数据结构队列的代码实现,可以简单的进行入队列和出队列的操作 /** * java数据结构之队列的实现 * 2016/4/27 **/ package cn.Link; import java ...

  10. Jenkins+SonarQube代码质量检查自动化

    基础概念百度百科:Jenkins是基于Java开发的一种持续集成工具,用于监控持续重复的工作,功能包括:1.持续的软件版本发布/测试项目.2.监控外部调用执行的工作.前面[Sonarqube 代码质量 ...