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?

Answers:

Answer

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");
Answer

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>

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.