I am trying to create a polling plugin called via $
("#element").poll();

Within the plugin I am calling the $.ajax function.  I have a default
success option within the plugin but also allow the developer to
override if needed.

The problem I am having is that withing the success of the ajax
function I have:  $(this).html(data).  That isn't being called and I
can't figure out why.

Here is my code:

    $.fn.poll = function(options){
        // extend our default options with those provided
        var opts = $.extend({}, $.fn.poll.defaults, options);
        setInterval(update, opts.interval);

        // method used to update element html
        function update(){
            $.ajax({
                type: opts.type,
                url: opts.url,
                success: opts.success
            });
        };
    };

    // default options
    $.fn.poll.defaults = {
        type: "POST",
        url: ".",
        success: function(data){
            $(this).html(data)
        },
        interval: 2000
    };

Can someone help me?

Reply via email to