首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

asp+xmlhttp解决方案

2012-06-07 
asp+xmlhttpHTML code%set xmlhttpServer.CreateObject(MSXML2.ServerXMLHTTP) dim xmlstr dim URLxml

asp+xmlhttp

HTML code
<%set xmlhttp=Server.CreateObject("MSXML2.ServerXMLHTTP") dim xmlstr dim URLxmlstr="<info><rec><depID>1</depID><smallClassID>20040212200856429814</smallClassID><type>1,3</type><keyWord>关键字1, 关键字2</keyWord><title>新闻标题</title><author>作者</author><original>原出处</original><content>新闻内容</content></rec></info>"  URL="http://10.10.12.36:80/receiveInfo.asp"dim xmlDocxmlhttp.open "GET","http://10.10.12.36:80/menu.xml",false xmlhttp.send(null)xmlDoc=xmlhttp.responseTextxmlstr=xmlDocresponse.Write(xmlDoc)xmlhttp.open "POST",URL, falsexmlhttp.send(xmlstr)if  err.number=0 thenresponse.Write(xmlhttp.status)response.Write(xmlHttp.ResponseText)       if xmlhttp.status <>"200" then              Response.Write "<font style='font-size:12px;color:red'>状态:"&xmlhttp.status&" ;描述:"&xmlHttp.ResponseText&"</font>"       else              Response.Write "<font style='font-size:12px;color:red'>  "&xmlHttp.ResponseText&"</font>"       end ifelse       Response.Write "<font style='font-size:12px;color:red'>状态:"&xmlhttp.status&" ;描述:"&xmlHttp.ResponseText&"</font>"end if%>


如果用xmlstr=xmlDoc,把xmlstr传过去,receiveInfo.asp页面xmldoc.load Request可以接收到数据,但是如果直接用赋值给xmlstr的那个数据,receiveInfo.asp页面xmldoc.load Request的数据为空,menu.xml里面的数据和赋值给xmlstr的那个数据一样的,求教怎么回事,为什么直接传过去不行呢??那个网上写的代码就是直接传过去,而不是需要从menu.xml里面读取啊

[解决办法]
Set xmlDoc=xmlhttp.responseXML


response.Write(xmlDoc.xml)
xmlhttp.open "POST",URL, false
xmlhttp.send(xmlDoc.xml)

或者
xmlhttp.send(xmlDoc)
[解决办法]
先膜拜楼上的
[解决办法]
xmlDoc.xml就是字符串啊

post方法需要加

var params = "data=" + escape(xmlDoc.xml);
xmlhttp.open "POST",URL, false
//需要加
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", params.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.send(params)
[解决办法]
application/x-www-form-urlencoded

热点排行