zoukankan
html css js c++ java
Basic of Ajax
<%
@ Page Language
=
"
C#
"
AutoEventWireup
=
"
true
"
CodeFile
=
"
CallWebService.aspx.cs
"
Inherits
=
"
CallWebService
"
%>
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
<
html
xmlns
="http://www.w3.org/1999/xhtml"
>
<
head
runat
="server"
>
<
title
>
Untitled Page
</
title
>
</
head
>
<
body
>
<
script
language
="javascript"
>
var
xmlhttp
=
false
;
try
{
xmlhttp
=
new
ActiveXObject(
"
Msxml2.XMLHTTP
"
);
}
catch
(e)
{
try
{
xmlhttp
=
new
ActiveXObject(
"
Microsoft.XMLHTTP
"
);
}
catch
(e)
{
xmlhttp
=
false
;
}
}
if
(
!
xmlhttp
&&
typeof
xmlhttp
!=
'
undefined
'
)
{
try
{
xmlhttp
=
new
XMLHttpRequest();
}
catch
(e)
{
xmlhttp
=
false
;
}
}
function
RequestByGet()
{
//
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
//
to call webservice
var
URL
=
"
http://localhost/webservicetest/service.asmx/GetDataSet?name=
"
+
document.getElementById(
"
txt
"
).value;
xmlhttp.Open(
"
GET
"
,URL,
true
);
xmlhttp.onreadystatechange
=
updatePage;
xmlhttp.Send(
null
);
//
var result = xmlhttp.status;
//
if(result == 200)
//
document.write(xmlhttp.responseText);
//
xmlhttp = null;
}
function
RequestByPost()
{
var
strPara
=
"
name=
"
+
document.getElementById(
"
txt
"
).value;
//
to call general .aspx file
var
URL
=
"
BeCalled.aspx
"
;
xmlhttp.Open(
"
POST
"
,URL,
false
);
xmlhttp.SetRequestHeader(
"
Content-Type
"
,
"
application/x-www-form-urlencoded
"
);
xmlhttp.SetRequestHeader(
"
Content-Length
"
,strPara.length);
xmlhttp.Send(strPara);
var
result
=
xmlhttp.status;
if
(result
==
200
)
document.write(xmlhttp.responseText);
else
alert(result);
xmlhttp
=
null
;
}
function
updatePage()
{
if
(xmlhttp.readyState
==
4
)
{
document.getElementById(
"
showstatus
"
).innerText
=
""
;
if
(xmlhttp.status
==
200
)
{
//
alert(xmlhttp.responseXML.xml);
document.getElementById(
"
age
"
).value
=
xmlhttp.responseXML.selectSingleNode(
"
//diffgr:diffgram/NewDataSet/Table1/b
"
).text;
}
else
if
(xmlhttp.status
==
404
)
alert(
"
Requested URL is not found.
"
);
else
if
(xmlhttp.status
==
403
)
alert(
"
Access denied.
"
);
else
alert(
"
error, status code:
"
+
xmlhttp.status);
}
else
document.getElementById(
"
showstatus
"
).innerText
=
"
loading
"
;
}
</
script
>
<
form
id
="form1"
runat
="server"
>
<
div
>
<
div
id
="showstatus"
></
div
>
<
input
type
="text"
id
="txt"
onchange
="RequestByGet()"
/>
<!--
<input type="button" value="CallWebServiceByGet" onclick="RequestByGet()" />
-->
<
input
type
="button"
value
="CallWebServiceByPost"
onclick
="RequestByPost()"
/>
<
br
/>
<
input
type
="text"
id
="age"
/>
</
div
>
</
form
>
</
body
>
</
html
>
查看全文
相关阅读:
加州大学伯克利分校Stat2.2x Probability 概率初步学习笔记: Section 1 The Two Fundamental Rules (1.5-1.6)
加州大学伯克利分校Stat2.2x Probability 概率初步学习笔记: Section 1 The Two Fundamental Rules (1.1-1.4)
加州大学伯克利分校Stat2.3x Inference 统计推断学习笔记: FINAL
加州大学伯克利分校Stat2.3x Inference 统计推断学习笔记: Section 5 Window to a Wider World
加州大学伯克利分校Stat2.3x Inference 统计推断学习笔记: Section 4 Dependent Samples
加州大学伯克利分校Stat2.3x Inference 统计推断学习笔记: Section 3 One-sample and two-sample tests
加州大学伯克利分校Stat2.3x Inference 统计推断学习笔记: Section 2 Testing Statistical Hypotheses
加州大学伯克利分校Stat2.3x Inference 统计推断学习笔记: Section 1 Estimating unknown parameters
求旋转数组的最小数字(剑指offer)
Vue创建局部组件
原文地址:https://www.cnblogs.com/silva/p/1044638.html
最新文章
经验交流List
6月9日任务
2013-2014-2学期,综合实训概况
如何解除依赖?
如何编写单元测试?
第7章 手工测试
第6章 系统测试
第5章 集成测试
寻找 n 个数中 k 个数的最小公倍数 x LCMSetEasy
hdu 4407 (12年 金华) 容斥原理 + map +筛选质因子
热门文章
hoj 大区间求质数个数 Count prime 线性筛素数
A-B Game 水题+longlong
hdu 4497 数论 质因子
Win7操作系统建立无线虚拟wifi
hdu 1659 综合数论+ 筛选欧拉函数 +质因子 +容斥原理
hdu 1796 容斥原理 + longlong
hdu 2136 数论+筛选质数+打表
hdu 数论+ 欧拉函数 1787
加州大学伯克利分校Stat2.2x Probability 概率初步学习笔记: Midterm
加州大学伯克利分校Stat2.2x Probability 概率初步学习笔记: Section 2 Random sampling with and without replacement
Copyright © 2011-2022 走看看