正好我也是这么用的!请看下面的例子:JS文件内容: function NoteShow(sNoteTime){
var sXML = '<NoteTime>' + sNoteTime + '</NoteTime>'
var xmlDoc = top.XMLHTTP("GetNotepadData.asp", sXML)
alert(xmlDoc.xml)
if (xmlDoc.xml == ''){
alert('数据载入失败!')
return
}
if (xmlDoc.firstChild.nodeName == 'error'){ //返回的是错误信息
alert(xmlDoc.firstChild.text)
return
}
function XMLHTTP(sURL, sXML){
var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP")
xmlhttp.Open("POST", sURL, false)
xmlhttp.Send(sXML)
return xmlhttp.responseXML
}
ASP文件内容:<!--#include file="Funciton.asp"-->
<%
Set xmlDoc = Server.CreateObject("Msxml2.DOMDocument")
xmlDoc.async = false
if not xmlDoc.load(Request) then
ReturnInfo("正要发向服务器的数据格式不正确!") '用<SPAN>标记是错误信息
end if
CreateServer() '此函数在Funciton.asp中,创建COM+对象
sResult = ServerObj.DateNotes(xmlDoc.xml, sXML) '第一个sXML是入口参数,把XML传给COM+,第二个是出口参数,由COM+返回的查询结果
CloseServer() '此函数在Funciton.asp中,释放COM+对象
ReturnInfo(sResult) function ReturnInfo(sResult)
if sResult = "OK" then
xmlDoc.loadxml(sXML)
else
xmlDoc.loadxml("<error>" & sResult & "</error>") '用<error>标记是错误信息
end if
Response.ContentType = "text/xml"
xmlDoc.save(Response)
Set xmlDoc = Nothing
end function%>
var sXML = '<NoteTime>' + sNoteTime + '</NoteTime>'
var xmlDoc = top.XMLHTTP("GetNotepadData.asp", sXML)
alert(xmlDoc.xml)
if (xmlDoc.xml == ''){
alert('数据载入失败!')
return
}
if (xmlDoc.firstChild.nodeName == 'error'){ //返回的是错误信息
alert(xmlDoc.firstChild.text)
return
}
function XMLHTTP(sURL, sXML){
var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP")
xmlhttp.Open("POST", sURL, false)
xmlhttp.Send(sXML)
return xmlhttp.responseXML
}
ASP文件内容:<!--#include file="Funciton.asp"-->
<%
Set xmlDoc = Server.CreateObject("Msxml2.DOMDocument")
xmlDoc.async = false
if not xmlDoc.load(Request) then
ReturnInfo("正要发向服务器的数据格式不正确!") '用<SPAN>标记是错误信息
end if
CreateServer() '此函数在Funciton.asp中,创建COM+对象
sResult = ServerObj.DateNotes(xmlDoc.xml, sXML) '第一个sXML是入口参数,把XML传给COM+,第二个是出口参数,由COM+返回的查询结果
CloseServer() '此函数在Funciton.asp中,释放COM+对象
ReturnInfo(sResult) function ReturnInfo(sResult)
if sResult = "OK" then
xmlDoc.loadxml(sXML)
else
xmlDoc.loadxml("<error>" & sResult & "</error>") '用<error>标记是错误信息
end if
Response.ContentType = "text/xml"
xmlDoc.save(Response)
Set xmlDoc = Nothing
end function%>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货