[英]can XML be send as response to iframe
I am trying send xml data as response to iframe
which is dynamically generated. 我正在尝试发送xml数据作为对动态生成的
iframe
响应。 i am sending the follwing data as response 我正在发送以下数据作为响应
out.println(
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" +
" <response> " + My_data + "</response>" );
when i check using firebug
i only see the follwing innerHTML
当我使用
firebug
检查时,我只看到下面的innerHTML
<response> My_data </response>
if i am trying to parse the xml i get uncaught exception: Invalid XML
error. 如果我尝试解析xml,则会遇到
uncaught exception: Invalid XML
错误。 here is my js
这是我的
js
var xml = this.contentDocument.body.innerHTML, /* this : iframe id */
xmlDoc = $.parseXML( xml ),
$xml = $( xmlDoc ),
$title = $xml.find( "<file-url>" );
alert($title.text());
How can i send XML response & parse. 我如何发送XML响应和解析。
It is generaly a good idea to use AJAX. 通常,使用AJAX是个好主意。 How do you actually load that xml into an IFRAME?
您实际上如何将该xml加载到IFRAME中? By using static SRC or Javascript?
通过使用静态SRC还是Javascript? You have also typos in your code.
您的代码中也有错别字。
This should work: 这应该工作:
var xml = this.contentDocument.body.innerHTML, /* this : iframe id */
var xmlDoc = $.parseXML( xml );
var $xml = $( xmlDoc );
var $title = $xml.find( "file-url" );
alert($title.text());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.