(function($) {
    $.fn.poll = function(options){
        var $this = $(this);
        // extend our default options with those provided
        var opts = $.extend(
			{}, 
			$.fn.poll.defaults, 
			options
		);
        
        // method used to update element html
        this.update = function(){
			$.ajax({
                type: opts.type,
                url: opts.url,
                success: opts.success
            });
        };
		
		this.init = function() {
			setInterval(this.update, opts.interval);
		}
		
		this.init();
    };

    // default options
    $.fn.poll.defaults = {
        type: "POST",
        url: ".",
        success: '',
        interval: 2000
    };
})(jQuery);
