如何使用脚本重新加载动态内容 [英] How to reload a dynamic content using script
本文介绍了如何使用脚本重新加载动态内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含动态数据的页面,我试图重新加载特定的< p>< / p>
。
HTML
< p id =spa<?php echo $ id;?> >< / p为H.
我的脚本就像这样
$(#spa+ id).load(location.href +#spa+ id);
但它不起作用,任何帮助都会真正被赞赏。
<以下显示了如何使用脚本添加新的脚本标记以重新载入。
< script language =text / javascript>函数load_js(){var head = document.getElementsByTagName('head')[0]; var script = document.createElement('script'); script.type ='text / javascript'; script.src ='source_file.js'; head.appendChild(脚本); } load_js();< / script>
插入一个新的脚本标签 - 你可以删除旧的标签,而不会有任何后果。如果您有缓存问题,您可能需要为查询字符串添加时间戳。
I have an page which contains dynamic data, I'm trying to reload particular <p></p>
only.
HTML
<p id="spa<?php echo $id; ?>"></p>
My script is something like this
$("#spa" + id).load(location.href + " #spa" + id);
But it's not working, any help will really be appreciated.
解决方案
Following shows how to add a new script tag to with the script to reload
<script language="text/javascript">
function load_js()
{
var head= document.getElementsByTagName('head')[0];
var script= document.createElement('script');
script.type= 'text/javascript';
script.src= 'source_file.js';
head.appendChild(script);
}
load_js();
</script>
The main point is inserting a new script tag -- you can remove the old one without consequence. You may need to add a timestamp to the query string if you have caching issues.
这篇关于如何使用脚本重新加载动态内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文