<!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>
<title>Ajaxed</title>
<style type="text/css">
.MyBody
{
background-color:Gray;
}
.Hidden
{
display:none;
}
.InsertVisible
{
display:block;
width:300px;
width:300px;
position:absolute;
left:200px;
top:200px;
zindex:2;
}
.cover {
background-color: #ffffff; /* the background */
filter:alpha(opacity=50); /* Internet Explorer */
-moz-opacity:0.5; /* Mozilla 1.6 and below */
opacity: 0.5; /* newer Mozilla and CSS-3 */
width:100%;
height:4000px;
position:absolute;
left:0px;
top:0px;
zindex:1;
}
</style>
<script type="text/javascript" src="json.js" ></script>
<script type="text/javascript">
//send request to web service
function SendRequest(url, params)
{
// Add some parameters to the query string
var pageUrl = url ;
// Initialize the XmlHttpRequest object
var xmlRequest, e;
try {
xmlRequest = new XMLHttpRequest();
}
catch(e) {
try {
xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e) {alert(e); }
}
// Prepare for a POST synchronous request
xmlRequest.open("POST", pageUrl, false);
xmlRequest.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
xmlRequest.send("param=" + params);
if (xmlRequest.readyState != 4) return;
if (xmlRequest.status == 200) {
} else {
alert(xmlRequest.responseText);
}
return xmlRequest;
}
//package the contact data into an object
// serialize it to a json string and send it to the webservice
function InsertRow()
{
var TextBoxCompanyName=document.getElementById("TextBoxCompanyName");
var TextBoxContactName=document.getElementById("TextBoxContactName");
var TextBoxContactTitle=document.getElementById("TextBoxContactTitle");
var Contact=new Object();
Contact.CompanyName=TextBoxCompanyName.value;
Contact.ContactName=TextBoxContactName.value;
Contact.ContactTitle=TextBoxContactTitle.value;
var sContact = Contact.toJSONString();
SendRequest("GetWebControl.asmx/InsertDataRow",sContact);
// reload the GridView Control
LoadGridView();
// Hide the insert row
document.getElementById("InsertWindow").className="Hidden";
document.getElementById("cover").className="Hidden";
}
// cancel the insert window
function Cancel()
{
document.getElementById("InsertWindow").className="Hidden";
document.getElementById("cover").className="Hidden";
}
// send request
// show the insert data dialog
function ShowInsertForm() {
var xml=SendRequest("GetWebControl.asmx/GetMyWebControl","InsertData.ascx");
document.getElementById("InsertWindow").innerHTML=GetXMLDOMContents(xml.responseXML.documentElement);
document.getElementById("InsertWindow").className="InsertVisible";
document.getElementById("cover").className="cover";
}
function GetXMLDOMContents(DOM)
{
if(DOM.text)
{
return DOM.text;
}
else
{
//FireFox uses a different name for this property
return DOM.textContent;
}
}
// Load the gridview control
function LoadGridView()
{
// Prepare for a POST synchronous request
var xml=SendRequest("GetWebControl.asmx/GetMyWebControl","GridView.ascx");
document.getElementById("MyFirstDiv").innerHTML=GetXMLDOMContents(xml.responseXML.documentElement);
}
</script>
</head>
<body id="MyBody" style="">
<input id="Button1" type="button" value="Insert Row" language="javascript" onclick="return ShowInsertForm()" />
<div id="cover" class="Hidden" > </div>
<div id="InsertWindow" class="Hidden" > </div>
<div id="MyFirstDiv" > </div>
<script type="text/javascript">
LoadGridView();
</script>
</body>
</html>
Ajaxify a simple HTML page using a web service
需积分: 0 100 浏览量
2008-10-16
11:44:56
上传
评论
收藏 88KB ZIP 举报
领君2018
- 粉丝: 204
- 资源: 1527
最新资源
- 鸢尾花(iris)数据集
- %E8%A7%86%E9%A2%91%E8%BD%AC%E9%9F%B3%E9%A2%9120240424092849.mp3
- 数据库中的分组查询及数据筛选
- J185-VB一款SOT23封装P-Channel场效应MOS管
- 计算整数各位数字之和,利用java代码实现
- J185-T2B-VB一款SOT23封装P-Channel场效应MOS管
- map20231226Kalmanfilter.ipynb
- J185-T1B-VB一款SOT23封装P-Channel场效应MOS管
- ASME Y14.5-2018 尺寸与公差标注 中文版
- J185-T1B-A-VB一款SOT23封装P-Channel场效应MOS管
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0