jQuery Heartbeat Plugin

July 24th, 2008 | by Alex

We have been developing the jHeartbeat plugin that can be used with the jQuery Javascript Framework library.

The plugin allows continuous AJAX requests that update a pre-specified or dynamically created DIV field.

The plugin only requires 10 lines of code where you need to specify the plugin location, the URL of where the AJAX request is polling and how often you would like the request to occur.

An example of the code is below:

<script type=”text/javascript” src=”js/jquery.js”></script>
<script type=”text/javascript” src=js/jheartbeat”></script>
<script type=”text/javascript”>
$(document).ready(function(){
$.jheartbeat.set({
url: “data.php”, // The URL that jHeartbeat will retrieve
delay: 1500, // How often jHeartbeat should retrieve the URL
div_id: “test_div” // Where the data will be appended.
, function (){
// Callback Function
});
});
});
</script>

The plugin can be downloaded, free of charge, from the jQuery Plugin Repository by clicking here!

  1. One Response to “jQuery Heartbeat Plugin”

  2. By newbie on Oct 2, 2008 | Reply

    How can I use this, for more than one url request, on different DIV on my page ?

You must be logged in to post a comment.