Using JavaScript to populate the content in a div
I've tried a few ways of doing this, the problem is our site is within a custom built CMS that won't allow us to use anything other than HTML and some JavaScript (it's very picky).
What I need to do is have a page within the CMS replace the content of one div on the page with the content of an outside php page.
Here's the code I'm currently using:
<script type="text/javascript">
$.ajax({
url: "http://website.com/files/table.php",
success: function(response){
$("#budget").append(response);
开发者_运维百科 }
});
</script>
<div id="budget"></div>
The sole content on the php page is a huge table (content being populated from a DB table). Inside the CMS that does not yield anything (literally blank), but on my test html page (not within the CMS) it works just fine. Does anyone know of any other possible solutions working with these types of restraints?
try
$("#budget").load("http://website.com/files/table.php");
or
a fragment from the table.php response
$("#budget").load("http://website.com/files/table.php #fragment");
You should be able to do this with 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>
精彩评论