More efficient method?
More efficient method?
Is there a more efficient method to go about doing this? I want to call the data on page load, and then start running through the intervals. My current setup:
- $(document).ready(function(){
- //run it on startup
- $.ajax({
- url: "js/latestNotice.php",
- cache: false
- }).done(function( notice ) {
- $("#notice").html('<b>Latest Notice:</b> ' + notice);
- });
-
- $.ajax({
- url: "js/online.php",
- cache: false
- }).done(function( online ) {
- $("#users").html(online);
- });
-
- setInterval(function(){
- $.ajax({
- url: "js/latestNotice.php",
- cache: false
- }).done(function( notice ) {
- $("#notice").html('<b>Latest Notice:</b> ' + notice);
- });
-
- $.ajax({
- url: "js/online.php",
- cache: false
- }).done(function( online ) {
- $("#users").html(online);
- });
- }, 15000);
- });