Reputation: 23
I already looked and couldn't find what I was looking for... So if this is already out there somewhere sorry..
What I am trying to do is <?php include('style/header.php') ?>
but instead of having to include it like that, I would like to call it with <div class="header"></div>
So when that div is used it gets replaced by whatever is in the php file.
I am doing this because I am working with a CMS editor that does not allow anything but div tags and basic html. However I can still add scripts and php to the page itself, (just not in the content area.) But I can get around this if I can include the php as a div...
If there is anyway I can do this with php, Jquery, or javascript that would be great!
Thanks in advance for any help!
Upvotes: 2
Views: 1011
Reputation: 2144
You can't include a PHP page by calling a div. But you may actually call that php page using JavaScript (ajax), get the data and finally set the data to your div. The solution below uses jQuery so be sure you have loaded jQuery in your page for it to work.
$.ajax({
url: "yourPage.php",
success: function(data){
$(".header").html(data);
}
});
Upvotes: 2