Skip to content

Instantly share code, notes, and snippets.

@rafarubert
Created August 30, 2011 17:53
Show Gist options
  • Select an option

  • Save rafarubert/1181514 to your computer and use it in GitHub Desktop.

Select an option

Save rafarubert/1181514 to your computer and use it in GitHub Desktop.
(function($) {
$.fn.poll = function(options){
var $this = $(this);
var opts = $.extend({}, $.fn.poll.defaults, options);
setInterval(update, opts.interval);
function update(){
$.ajax({
type: opts.type,
url: opts.url,
success: opts.success,
error: function (request, status, error) {
//console.log("Ocorreu um erro: "+error);
}
});
};
};
$.fn.poll.defaults = {
type: "GET",
url: ".",
success: function(){console.log("ola")},
interval: 180000
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment