![](/img/trans.png)
[英]Javascript - populate a div with content from a hidden div using click buttons
[英]Using JavaScript to populate the content in a div
我尝试了几种方法,问题是我们的网站是在一个自定义构建的CMS中,不允许我们使用除HTML和一些JavaScript之外的任何东西(它非常挑剔)。
我需要做的是让CMS中的页面用外部php页面的内容替换页面上一个div的内容。
这是我目前使用的代码:
<script type="text/javascript">
$.ajax({
url: "http://website.com/files/table.php",
success: function(response){
$("#budget").append(response);
}
});
</script>
<div id="budget"></div>
php页面上唯一的内容是一个巨大的表格(内容从数据库表中填充)。 在CMS内部不产生任何东西(字面上是空白的),但在我的测试html页面(不在CMS中)它工作得很好。 有没有人知道使用这些类型限制的任何其他可能的解决方案?
尝试
$("#budget").load("http://website.com/files/table.php");
要么
table.php响应中的一个片段
$("#budget").load("http://website.com/files/table.php #fragment");
您应该可以使用jquery(http://jquery.com/)执行此操作
<script type='text/javascript'>
$.get("table.php", function (data) //gets the code behind the page
{
$("#budget").html(data); //places the data in the budget div
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.