zoukankan
html css js c++ java
有XMLHTTP实现无刷新功能[原创]
Rss.aspx.cs
using
System;
using
System.Data;
using
System.Web;
using
System.Xml;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
System.Web.UI.HtmlControls;
using
Power.Rss;
public
partial
class
Rss : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
ProblemXML xml
=
new
ProblemXML();
string
username
=
""
;
string
password
=
""
;
string
category
=
"
0
"
;
string
pageSize
=
"
20
"
;
string
pageIndex
=
"
1
"
;
string
subModuleID
=
"
0
"
;
XmlDocument doc
=
new
XmlDocument();
try
{
doc.Load(Request.InputStream);
}
catch
{
xml.PutError(ProblemXML.INPUT_ERROR);
return
;
}
if
(doc.HasChildNodes)
{
username
=
doc.DocumentElement.SelectSingleNode(
"
//username
"
)
==
null
?
""
: doc.DocumentElement.SelectSingleNode(
"
//username
"
).InnerText.Trim();
password
=
doc.DocumentElement.SelectSingleNode(
"
//password
"
)
==
null
?
""
: doc.DocumentElement.SelectSingleNode(
"
//password
"
).InnerText.Trim();
category
=
doc.DocumentElement.SelectSingleNode(
"
//category
"
)
==
null
?
"
0
"
: doc.DocumentElement.SelectSingleNode(
"
//category
"
).InnerText;
pageSize
=
doc.DocumentElement.SelectSingleNode(
"
//pageSize
"
)
==
null
?
"
20
"
: doc.DocumentElement.SelectSingleNode(
"
//pageSize
"
).InnerText;
pageIndex
=
doc.DocumentElement.SelectSingleNode(
"
//pageIndex
"
)
==
null
?
"
1
"
: doc.DocumentElement.SelectSingleNode(
"
//pageIndex
"
).InnerText;
subModuleID
=
doc.DocumentElement.SelectSingleNode(
"
//ModuleID
"
)
==
null
?
"
0
"
: doc.DocumentElement.SelectSingleNode(
"
//ModuleID
"
).InnerText;
}
//
验证
if
(xml.CheckUser(username, password))
{
try
{
xml.PutProblemXML(Convert.ToUInt32(category), Convert.ToUInt32(pageSize), Convert.ToUInt32(pageIndex), username,subModuleID);
}
catch
(Exception ex)
{
xml.PutError(ex.Message);
}
}
else
{
xml.PutError(ProblemXML.INPUT_PASSWORD_ERROR);
}
}
}
testRss.htm
<!
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
>
XmlHttp测试
</
title
>
<
script
type
="text/javascript"
>
function
testxml()
{
var
username
=
document.getElementById(
"
txtUserName
"
).value;
var
password
=
document.getElementById(
"
txtPassword
"
).value;
var
pageSize
=
document.getElementById(
"
PageSize
"
).value;
var
pageIndex
=
document.getElementById(
"
PageIndex
"
).value;
var
ModuleID;
var
category;
for
(
var
i
=
0
;i
<
document.getElementById(
"
SelSubModule
"
).options.length;i
++
)
{
if
(document.getElementById(
"
SelSubModule
"
).options[i].selected)
{
var
ModuleID
=
document.getElementById(
"
SelSubModule
"
).options[i].value;
}
}
for
(
var
i
=
0
;i
<
document.getElementById(
"
SelCategory
"
).options.length;i
++
)
{
if
(document.getElementById(
"
SelCategory
"
).options[i].selected)
{
category
=
document.getElementById(
"
SelCategory
"
).options[i].value;
}
}
var
strXML
=
"
<Client>\r\n<FormData>\r\n
"
;
strXML
+=
"
<username>
"
+
username
+
"
</username>\r\n
"
;
strXML
+=
"
<password>
"
+
password
+
"
</password>\r\n
"
;
strXML
+=
"
<category>
"
+
category
+
"
</category>\r\n
"
;
strXML
+=
"
<pageSize>
"
+
pageSize
+
"
</pageSize>\r\n
"
;
strXML
+=
"
<pageIndex>
"
+
pageIndex
+
"
</pageIndex>\r\n
"
;
strXML
+=
"
<ModuleID>
"
+
ModuleID
+
"
</ModuleID>\r\n
"
;
strXML
+=
"
</FormData>\r\n</Client>
"
var
xmlhttp
=
new
ActiveXObject(
"
Msxml2.XMLHTTP
"
);
xmlhttp.open('POST','Rss.aspx',
false
);
xmlhttp.send(strXML);
if
(xmlhttp.readyState
==
4
)
{
document.getElementById(
"
div1
"
).innerText
=
xmlhttp.responseText;
}
}
function
GetSubModule()
{
xmlModule
=
new
ActiveXObject(
"
Msxml2.XMLHTTP
"
);
xmlModule.open(
"
get
"
,
"
Rss_SubModule.aspx
"
,
true
);
xmlModule.onreadystatechange
=
ShowModule;
xmlModule.send(
null
);
}
function
ShowModule()
{
if
(xmlModule.readyState
==
4
)
{
if
(xmlModule.status
==
200
)
{
var
doc
=
new
ActiveXObject(
"
Msxml2.DOMDocument
"
);
doc.loadXML(xmlModule.responseText);
var
items
=
doc.getElementsByTagName(
"
SubModule
"
);
for
(
var
i
=
0
; i
<
items.length ; i
++
)
{
var
op
=
document.createElement(
"
option
"
);
op.value
=
items[i].getElementsByTagName(
"
SubModuleID
"
)[
0
].firstChild.nodeValue;
var
txt
=
document.createTextNode(items[i].getElementsByTagName(
"
SubModuleName
"
)[
0
].firstChild.nodeValue);
op.appendChild(txt);
document.getElementById(
"
SelSubModule
"
).appendChild(op);
}
}
else
{
alert(xmlModule.statusText);
}
}
}
</
script
>
</
head
>
<
body
style
="font-size:12px"
onload
="GetSubModule()"
>
<
div
>
<
table
border
="0"
cellpadding
="2"
cellspacing
="1"
style
="background-color: #a9a9a9"
>
<
tr
>
<
td
style
=" 100px; background-color: #ffffff;"
>
用户名:
</
td
>
<
td
style
="background-color: #ffffff;"
>
<
input
id
="txtUserName"
type
="text"
/></
td
>
</
tr
>
<
tr
>
<
td
style
=" 100px; background-color: #ffffff;"
>
密
码:
</
td
>
<
td
style
="background-color: #ffffff;"
>
<
input
id
="txtPassword"
style
=" 150px"
type
="password"
/></
td
>
</
tr
>
<
tr
>
<
td
style
=" 100px; background-color: #ffffff;"
>
页分大小:
</
td
>
<
td
style
="background-color: #ffffff;"
>
<
input
id
="PageSize"
type
="text"
value
="20"
/></
td
>
</
tr
>
<
tr
>
<
td
style
=" 100px; background-color: #ffffff;"
>
页分索引:
</
td
>
<
td
style
="background-color: #ffffff;"
>
<
input
id
="PageIndex"
type
="text"
value
="1"
/></
td
>
</
tr
>
<
tr
>
<
td
style
=" 100px; background-color: #ffffff;"
>
模块节点:
</
td
>
<
td
style
="background-color: #ffffff;"
>
<
select
id
="SelSubModule"
style
=" 155px"
>
<
option
selected
="selected"
value
="0"
>
全部类型
</
option
>
</
select
>
</
td
>
</
tr
>
<
tr
>
<
td
style
=" 100px; background-color: #ffffff"
>
分 类:
</
td
>
<
td
style
="background-color: #ffffff"
>
<
select
id
="SelCategory"
style
=" 154px"
>
<
option
selected
="selected"
value
="0"
>
全部问题
</
option
>
<
option
value
="1"
>
已解决的问题
</
option
>
<
option
value
="2"
>
未解决的问题
</
option
>
<
option
value
="3"
>
我解决的问题
</
option
>
<
option
value
="4"
>
我未解决的问题
</
option
>
<
option
value
="5"
>
未回复的问题
</
option
>
<
option
value
="6"
>
回复后又修改的问题
</
option
>
</
select
>
</
td
>
</
tr
>
<
tr
>
<
td
colspan
="2"
style
="background-color: #ffffff"
align
="center"
>
<
input
id
="Button1"
type
="button"
value
="button"
onclick
="testxml()"
/></
td
>
</
tr
>
</
table
>
<
div
id
="div1"
style
="background-color:#ffffe9 ;"
></
div
>
</
div
>
</
body
>
</
html
>
查看全文
相关阅读:
一些jquery常用方法
如何判断js中的数据类型
SDL结合QWidget的简单使用说明(2)
C++引用详解
SDL结合QWidget的简单使用说明
Qt::浅谈信号槽连接,参数在多线程中的使用
Qt::带返回值的信号发射方式
Windows:子线程中创建窗口
Qt:小项目仿QQ修改头像界面,技术点记录
Qt::QWindow多窗口争抢置顶状态解决方案
原文地址:https://www.cnblogs.com/ghx88/p/441667.html
最新文章
Linux中变量$#,$@,$0,$1,$2,$*,$$,$?的含义
Ubuntu14.04 安装 Sublime Text 3
Python之CMDB资产管理系统
Django rest framwork-CMDB API实战
Django rest framwork
Celery异步任务队列/周期任务+ RabbitMQ + Django
python类和对象-扩展
算法之常用排序:冒泡排序、选择排序、插入排序
Scrapy爬虫框架之爬取校花网图片
Django-Model操作数据库(增删改查、连表结构)
热门文章
Django-Form表单(验证、定制、错误信息、Select)
Django进阶(路由系统、中间件、缓存、Cookie和Session、Ajax发送数据
使用Git将码云上的代码Clone至本地
better-scroll的用法,及其中的一个属性event._constructed详解
基于webpack的Vue.js开发环境快速搭建
viewer.js--一个强大的jQuery图像查看插件
canvas动画--demo
一些js知识点总结
CSS使文字、大小不固定的图片垂直居中
jquery去掉click事件
Copyright © 2011-2022 走看看