AJAX Call中的强制Document.write

[英]Mandatory Document.write in AJAX Call


We currently have a search page where hotels are listed dynamically via ajax calls.And per displayed hotel we have to display a tripadvisor widget. A sample tripadvisor widget code is as follows

我们目前有一个搜索页面,通过ajax调用动态列出酒店。每个显示的酒店我们必须显示tripadvisor小部件。示例tripadvisor小部件代码如下

<div id="TA_rated485" class="TA_rated">
<ul id="mdJZap41Mwg" class="TA_links shznH7pJf">
<li id="NnfwdIAYy" class="e9ZmnKZxo"><a href=http://www.tripadvisor.com/Hotel_Review-g190454-d228070-Reviews-Hotel_Royal-Vienna.html>Hotel Royal</a></li>
</ul>
</div>
<script src="http://www.jscache.com/wejs?wtype=rated&amp;uniq=485&amp;locationId=228070&amp;lang=en_US"></script>

The fun part is that the script tag links to a script which uses document.write. As this is after the page onload and called during an ajax call loop the document gets rewritten. Is there any work around in order to have the document.write not rewrite the page or a workaround for the widget where the widget is integrated in a different way other than the current document.write technique.

有趣的部分是脚本标记链接到使用document.write的脚本。因为这是在页面onload之后并且在ajax调用循环期间调用,所以文档被重写。是否有任何解决方法,以使document.write不重写页面或窗口小部件的解决方法,其中窗口小部件以不同于当前document.write技术的方式集成。

1 个解决方案

#1


0  

This link may help you out with this issue

此链接可能会帮助您解决此问题

JavaScript Document.Write Replaces All Body Content When Using AJAX

JavaScript Document.Write在使用AJAX时替换所有正文内容

or

you can go for jquery method

你可以去jquery方法

 $('slector').live(event,function(){
 //your code here
 });

This will bind your code to dynamically loaded element by Ajax.

这将通过Ajax将代码绑定到动态加载的元素。

智能推荐

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2012/08/30/73415b7687ac7240557c11d823cf1b67.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告