Created
May 1, 2013 16:23
-
-
Save Narven/5496335 to your computer and use it in GitHub Desktop.
jquery kind of cron job :P
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // CHECK NEW MESSAGES (CRON) | |
| (function checkNewMessages() { | |
| $.ajax({ | |
| url: "<?=site_url('message/process')?>", | |
| type: 'post', | |
| data: {'job': 'checkNewMessages'}, | |
| success: function(data) { | |
| //console.info(data); | |
| var data = $.parseJSON(data); | |
| //console.info(data); | |
| if(data.info == 'success') | |
| { | |
| //alert(data.result); | |
| if($('#counter').length > 0) | |
| { | |
| $('#counter').html(parseInt(data.result)); | |
| } | |
| } | |
| else | |
| { | |
| if($('#counter').length > 0) | |
| { | |
| $('#counter').html(''); | |
| } | |
| } | |
| }, | |
| complete: function() { | |
| // Schedule the next request when the current one's complete | |
| setTimeout(checkNewMessages, 5000); | |
| } | |
| }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment