Consider the following AJAX call to load RSS news data on click event:
$(function() {
$(document).ready(function() {
$('.msg_head').eq(0).click(function(){
$('.msg_body').eq(0).load('printSideNews.php');
$('.loadMessage').eq(2).hide();
});
});
});
printSideNews.php
looks like this:
include ('newsFeed.php');
function printNewsMenu($itemD){
for ($i = 0; $i < 4; $i++) {
if($itemD==null)
echo "An error has occured, please try again later";
$article_title = $itemD[$i]->title;
$article_link = $itemD[$i]->link;
echo "<a href='".$article_link."' title='".$article_title."' target='_blank'>". $article_title. " </a></br>". PHP_EOL;
}
printNewsMenu($itemD);
The included newsFeed.php
file lloks like:
$urlD = "someurl";
$xmlD = simplexml_load_file($urlD);
$itemD = $xmlD->channel->item;
I need to cache the $itemD
or the $xmlD
object - not sure which one. This should be cached for 1 hour then taken again from the url. Any help with code caching this mess will be greatly appreciated.