I have been reading and playing around with jQuery and can do
somethings, but making a plugin is hurting my brain. Here is what I
have.

(function($) {
        $.fn.myPlugin = function() {

                this.each(function() {
                        alert(this.id)
                        $.get("return.php",function(data) {
                                alert(this.id);
                                //do something with "this" & the "data"
                        });
                });
                return this;
        };
})(jQuery);

$(document).ready(function(){
  $("div").myPlugin();
});

<div id="myID"></div>

Here is what I don't understand. The first alert shows the id, but the
second one does not, It alerts "undefined". I want to be able to
modify the object ("this) after receiving the data from the ajax.

Reply via email to