无法读取 httpservice 的输出
我有一个 HTTPservice
id="myhttp"
url="site.com/script.php"
method="POST"
resultFormat="xml"
它使用的脚本返回
$output = '<worked>' . $worked . '</worked>';
echo $output;
问题是当我尝试读取 worked
时,它告诉我变量 worked
不存在
event.result.worked
myhttp.lastResult.worked
唯一的有效的方法是使用 toString()
myhttp.lastResult.toString()
or event.result.toString()
我做错了什么?
- 我计划向输出
time
添加其他变量,因此需要分别访问每个time
和worked
。 - 我可能还需要返回多个响应,每个响应都有自己的
worked
和time
值。我该怎么做呢。我想不要使用 XML。有没有更轻量的选择。 Flex 显示我有以下选项:array
e4x
flashvars
object
text
xml
I have an HTTPservice
id="myhttp"
url="site.com/script.php"
method="POST"
resultFormat="xml"
The script it uses returns
$output = '<worked>' . $worked . '</worked>';
echo $output;
Problem is when I try to read worked
, it tells me the variable worked
is not there
event.result.worked
myhttp.lastResult.worked
The only thing that works is using toString()
myhttp.lastResult.toString()
or event.result.toString()
What am I doing wrong?
- I plan to add other variables to the output
time
, so need to access eachtime
andworked
separately. - I may also need to return multiple responses each with their own
worked
andtime
values. How do I do that. I was thinking to not use XML. Is there a more lightweight option. Flex shows I have the following options:array
e4x
flashvars
object
text
xml
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该使用 e4x 作为返回类型。通过将返回类型声明为 xml,您可以告诉 flex 将其处理为 XMLNode,这是遗留的,不应使用。
如果出于某种未知原因需要使用 XMLNode,可以使用 event.result.nodeValue 获取文本的值。
You should use e4x as your return type. By declaring your return type as xml, you tell flex to handle it as an XMLNode, which is legacy and shouldn't be used.
If you need to use XMLNode for some unknown reason, you can get the value of the text by using event.result.nodeValue.
您的返回类型应该是 e4x 吗?
Should your return type be e4x?