What is the best way of loading the content of a html page into another webpage? Lets say i have a front page (index.php) where i can choose between PHP and javascript and i dont have to care about compatibiliy, mobile users etc.
In the past, i used the include()/include_once() function in php to do something like this to load the content of my content, which i have put in the content.html, into the div-container on my index.php:
<div id="content">
<?php include("content.html"); ?>
</div>
But i could do pretty much the same thing using javascript/jquery:
$("#content").load("content.html");
But what is the best way to do it? I know that you cant really compare PHP to javascript. Normally i would only use javascript for user interface stuff. Especially with jquery's load() function its very easy to load content from a file into a div and replace PHP's include(). But just because it can be done, doesnt mean in should be done.
Is there any kind of best practice? What are the pros/cons on using javascript for this?