我在从ASP页面检索变量时遇到了一些麻烦。它返回整个页面,而我只需要页面中的变量strAnswer。请帮帮忙?
这是我的代码:
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onDataSaved);
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
var request:URLRequest = new URLRequest("http://" + host + urlPath + "setXML.asp");
request.method = URLRequestMethod.POST;
var variables:URLVariables = new URLVariables();
variables.xmlString = str;
variables.eltGuid = eltGuid;
request.data = variables;
loader.load(request);
private function onDataSaved(e:Event):void
{
var loader2:URLLoader = URLLoader(e.target);
loader2.dataFormat = URLLoaderDataFormat.VARIABLES;
trace(loader2.data.strAnswer);
}
ASP页面:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1
%>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>setASP</title>
</head>
<body>
<%
Dim xmlBlock, strEltGuid, objRQL
xmlBlock = escape(Request.Form("xmlString"))
strEltGuid = Request.Form("eltGuid")
'---------------------------
'Post to RedDot CMS via RQL
'---------------------------
Set objRQL = Server.CreateObject("RDCMSASP.RdPageData")
objRQL.XMLServerClassname = "RDCMSServer.XmlServer"
xmlData = "<IODATA loginguid=" & Chr(34) & Session("LoginGuid") & Chr(34) & " format=" & Chr(34) & "1" & Chr(34) & " sessionkey=" & Chr(34) & Session("SessionKey") & Chr(34) & "><ELT translationmode='0' extendedinfo='' reddotcacheguid='' action='save' guid='" & strEltGuid & "' pageid='' id='' index='' type='31'>" & xmlBlock & "</ELT></IODATA>"
'Response.Write(xmlBlock)
'Response.Write(strEltGuid)
objRQL.ServerExecuteXML xmlData, rqlError
If rqlError <> "" Then
Response.Write rqlError
Else
strAnswer = "strResponse=Just a test! How strange. ..."
Response.Write (strAnswer)
'Response.Write "strResponse=Just a test! How strange. ..."
'Response.Write "Saved successfully." '"Saved successfully." '
End If
'Response.Write "strResponse=Just a test! How strange. ..."
'------------------
'Be a good citizen
'------------------
Set objRQL = Nothing
%>
</body>
</html>
答案 0 :(得分:4)
您正在创建并加载html页面。如果你删除所有的html标签,只使用Response.Write输出变量,那应该可以。
我过去常常这样做,将动态生成的XML从ASP加载到Flash中。我在这里有关于此的博文:http://www.herrodius.com/blog/18