This is code i use for RodjaTV to update news from text file.
$(document).ready(function() {
$("p.update").load("news.txt");
var refreshId = setInterval(function() { $("p.update").load('news.txt'); }, 9000);
$.ajaxSetup({ cache: false });
});
code in the body
<div class="news"><marquee behavior="scroll" scrollamount="2" direction="left"><p class="update"><?php // include('news.txt');?></p></marquee></div>
This script uses a simple PHP based RSS parser called LastRSS for retrieving a RSS feed, then Ajax and DHTML to display the feed dynamically and with flare.
the script can be set to refetch the external file periodically, so any changes to the external file is reflected and shown inside the ticker without the user having to reload the page.
FusionCharts Free can be easily used in dynamic web applications, static websites or be combined with Javascript to render a true AJAX experience.
In this tutorial we are making a simple AJAX-ed Todo List App, with PHP, MySQL and jQuery. In the process we are going to demonstrate PHP’s OOP capabilities, play with jQuery UI and implement some nice AJAX functionality.
In this tutorial we’ll build a nice-looking, embedded Ajax contact form that the user can summon up by clicking a link in the page. Along the way, we’ll explore various topics, including:
- HTML5 form fields
- How to use fallback techniques to make the form function even if the browser has JavaScript turned off
- Using CSS techniques to create attractive forms
- Writing a secure form mailer using PHP
- Animating page elements with jQuery, and, of course…
- Using jQuery to make Ajax requests
MarPlo CMS Blog Features
- SEO Friendly URLs.
- Accesible from Desktop Web browsers, and Mobile Devices.
- Double Cache system (on server, and on client side), that makes the content to load very fast, and uses very little bandwidth.
- Each Category and Article can be set to load or not via Ajax.
- Valid HTML5 (works also on Internet Explorer versions that not support HTML5).
- Easy Administrator Management (create, modify, delete Categories and Articles, directy from WebPage).
- Easy to create own Template.
- Easy to translate it to be used in other languages than English.
- Auto create Menu, Archive, and RSS Feed.
- The user can write comments in the blog-page, and chooses notification of new comments.
Target: Click on the entry titles from homepage, then load the content without AJAX refreshing, and display the SlideDown effect with jQuery.
HTML Structure:
<div class="post-home">
<div class="post-title"><h2>title</h2></div>
<div class="post-content"><p>content</p>
</div>
In functions.php, add:
function ajax_post(){
if( isset($_GET['action'])&& $_GET['action'] == 'ajax_post'){
$ariticle_id=$_GET['id'];
query_posts("p=$ariticle_id");the_post();the_content();
die();
}else{
return;
}
}
add_action('init', 'ajax_post');
Then we can display the content of id=123 entry using links like http://YOU-DOMAIN.COM/?action=ajax_post&id=123.
The jQuery AJAX code:
$('#postlist .post-home .post-title').click(function() { //The event of clicking on titles
if($(this).next().html()=="" || $(this).next().is(":hidden")){ //If the entry has no content or is 'display:none', implement following code
var postId=$(this).parent().attr("id").replace(/^post-(.*)$/,'$1'); //Get entry ID
var postContent=$(this).next();
$.ajax({
url:"?action=ajax_post&id="+postId,
success:function(data){
$('#postlist .post-home .post-content').slideUp(500);
postContent.html(data).slideDown(500);
}
});
return false;
}else{ //Or, implement following code
$(this).children().children().text('LOADING......'); /change title
window.location = $(this).children().children().attr('href'); //Open article link
}
});
It’s a simple but useful tutorial for those who need to know how to load dynamically some static content in their websites via AJAX.