开发者

How receive xml code without AJAX

In an app that i'am creating i have to receive from the server an xml string with this format eg: <reply> <script> alert('Hello World!'); </script> </reply> when i did this using ajax work perferct, but when i try to receive the data in an i开发者_JAVA技巧frame i can't extract the data from the frame because is not there, IE and FF open new tabs and append the data on that tab, how i avoid that and makes them insert the data on the frame.


I can do this work still using Javascript, get the result of the ajax and write it inside the iframe:

  1. first create your iframe tag like this:

  2. than the javascript code to insert the ajax:

    var t = document.getElementById('iftarget');

    h = t.contentWindow.document.getElementsByTagName('html');

    h[0].innerHTML = '<h1>Hello</h1> This must work! Put your data here';

I have created a jsFiddle for this http://jsfiddle.net/nunomazer/JGyEr/

Best Regards

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜