高手指教
时间:2005-06-02
来源:互联网
我一段代码,出错,大家看看
指示docResponse.selectSingleNode少了对像,头好大啊,哪位高手看看,谢了
==================test.asp======================
<body>
<form name="add" method="post" action="eq_history_add.asp">
<table width="600" border="1" cellspacing="0" align="center"cellpadding="3" bordercolordark="#000000" bordercolorlight="#FFFFFF">
<tr>
<td>故障原因</td>
<td><textarea name="eresion" rows="5" cols="50" ></textarea>
<input type="text" name="key_word" onBlur="check_result()"></td>
</tr>
<tr>
<td>處理結果</td>
<td><textarea name="eresult" rows="5" cols="50"></textarea></td>
</tr>
</table>
</form>
</body>
</html>
<script language="vbscript">
Sub check_result()
if len(add.key_word.value) <> 0 then
dim sql, docSubmit, poster, docResponse, state, result
sql = "<root><part qu_title='" & add.key_word.value & "' /></root>"
Set docSubmit = CreateObject("Microsoft.XMLDOM")
docSubmit.async = False
docSubmit.loadXML sql
Set poster = CreateObject("Microsoft.XMLHTTP")
poster.Open "POST", "checkresult.asp", False
poster.send docSubmit
Set docResponse = poster.responseXML
state= docResponse.selectSingleNode("//errorcode").getAttribute("state")
result= docResponse.selectSingleNode("//errorcode").getAttribute("result")
if state <> "Y" then
add.eresult.value = docResponse.selectSingleNode("//errorcode").getAttribute("qu_result")
msgbox result,16,"錯誤提示"
add.key_word.select
else
add.eresult.value = docResponse.selectSingleNode("//errorcode").getAttribute("qu_result")
end if
else
add.eresult.value = ""
end if
end Sub
</script>
=================checkresult.asp====================
<%@ Language=VBScript CODEPAGE="950"%>
<%Response.Buffer=True%>
<!--CheckPart_c.asp-->
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<!--#include file="datalink.asp" -->
<%
Response.ContentType = "text/xml"
dim key_word, pro_check
dim SQLStm, rs
dim docReceived, state , result
Set docReceived = CreateObject("Microsoft.XMLDOM")
docReceived.async = False
docReceived.load Request
key_word = docReceived.selectSingleNode("//part").getAttribute("key_word")
SQLStm = "select * from eq_qu_det where qu_title = '" & key_word & "'"
set rs = Conn.Execute(SQLStm)
%>
<?xml version="1.0" encoding="big5"?>
<%
if rs.EOF then
response.Write "<errorcode state ='N' result ='沒有你要找的記錄' pro_check='無效關鍵字' />"
else
response.Write "<errorcode state ='Y' result ='' qu_result='"& rs("qu_result") &"' />"
end if
rs.Close
Set Rs=nothing
conn.Close
Set conn=nothing
%>
指示docResponse.selectSingleNode少了对像,头好大啊,哪位高手看看,谢了
==================test.asp======================
<body>
<form name="add" method="post" action="eq_history_add.asp">
<table width="600" border="1" cellspacing="0" align="center"cellpadding="3" bordercolordark="#000000" bordercolorlight="#FFFFFF">
<tr>
<td>故障原因</td>
<td><textarea name="eresion" rows="5" cols="50" ></textarea>
<input type="text" name="key_word" onBlur="check_result()"></td>
</tr>
<tr>
<td>處理結果</td>
<td><textarea name="eresult" rows="5" cols="50"></textarea></td>
</tr>
</table>
</form>
</body>
</html>
<script language="vbscript">
Sub check_result()
if len(add.key_word.value) <> 0 then
dim sql, docSubmit, poster, docResponse, state, result
sql = "<root><part qu_title='" & add.key_word.value & "' /></root>"
Set docSubmit = CreateObject("Microsoft.XMLDOM")
docSubmit.async = False
docSubmit.loadXML sql
Set poster = CreateObject("Microsoft.XMLHTTP")
poster.Open "POST", "checkresult.asp", False
poster.send docSubmit
Set docResponse = poster.responseXML
state= docResponse.selectSingleNode("//errorcode").getAttribute("state")
result= docResponse.selectSingleNode("//errorcode").getAttribute("result")
if state <> "Y" then
add.eresult.value = docResponse.selectSingleNode("//errorcode").getAttribute("qu_result")
msgbox result,16,"錯誤提示"
add.key_word.select
else
add.eresult.value = docResponse.selectSingleNode("//errorcode").getAttribute("qu_result")
end if
else
add.eresult.value = ""
end if
end Sub
</script>
=================checkresult.asp====================
<%@ Language=VBScript CODEPAGE="950"%>
<%Response.Buffer=True%>
<!--CheckPart_c.asp-->
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<!--#include file="datalink.asp" -->
<%
Response.ContentType = "text/xml"
dim key_word, pro_check
dim SQLStm, rs
dim docReceived, state , result
Set docReceived = CreateObject("Microsoft.XMLDOM")
docReceived.async = False
docReceived.load Request
key_word = docReceived.selectSingleNode("//part").getAttribute("key_word")
SQLStm = "select * from eq_qu_det where qu_title = '" & key_word & "'"
set rs = Conn.Execute(SQLStm)
%>
<?xml version="1.0" encoding="big5"?>
<%
if rs.EOF then
response.Write "<errorcode state ='N' result ='沒有你要找的記錄' pro_check='無效關鍵字' />"
else
response.Write "<errorcode state ='Y' result ='' qu_result='"& rs("qu_result") &"' />"
end if
rs.Close
Set Rs=nothing
conn.Close
Set conn=nothing
%>
作者: jwwu 发布时间: 2005-06-02
呵呵.. alert(docResponse.xml) 有数据吗?
asp 返回 xml 的格式一定要正确.
asp 返回 xml 的格式一定要正确.
作者: ※潇洒※ 发布时间: 2005-06-04
asp输出一定要是标准的 XML 格式 responseXML 才有值.
像你这个代码里asp输出的第一行是
<meta http-equiv="Content-Type" content="text/html; charset=big5">
肯定出错.
xml 文件要求第一行一定是<?xml version="1.0" encoding="***"?>
我改成以下格式测试通过.
<?xml version="1.0" encoding="big5"?> <% Response.CharSet ="big5" Response.ContentType = "text/xml" '其余代码略 %> <errorcode state ='N' result ='沒有你要找的記錄' pro_check='無效關鍵字' />
提示:您可以先修改部分代码再运行
像你这个代码里asp输出的第一行是
<meta http-equiv="Content-Type" content="text/html; charset=big5">
肯定出错.
xml 文件要求第一行一定是<?xml version="1.0" encoding="***"?>
我改成以下格式测试通过.
<?xml version="1.0" encoding="big5"?> <% Response.CharSet ="big5" Response.ContentType = "text/xml" '其余代码略 %> <errorcode state ='N' result ='沒有你要找的記錄' pro_check='無效關鍵字' />
提示:您可以先修改部分代码再运行
作者: ※潇洒※ 发布时间: 2005-06-04
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28