Test case for jQuery Ticket 7640

additional ajax events not needed? I guess context is enough.

by jitter

HTML

<div id="d1" data-imgsrc="http://i56.tinypic.com/344s2lz.gif"></div>
<div id="d2" data-imgsrc="http://www.glitzertext.gif-paradies.de/0010/z4cf0452547ad2.gif"></div>

CSS

#d1, #d2 {
    border: 1px solid black;
    margin: 10px;
    padding: 10px;
}

JavaScript

$.ajaxSetup({
    url: "/echo/html/",
    type: "POST",
    dataType: "html",
    success: function(data) {
        var $this = $(this);
        $this.append("<p>Loading successful..." + this.id + "</p>");
        $this.append(data);
    },
    complete: function() {
        $(this).append("<p>Loading completed..." + this.id + "</p>");
    }
});

$("#d1, #d2").each(function(i, ele) {
    var $e = $(ele);
    $e.ajaxSend(function() {
        $(this).append("<p>Loading started..." + this.id + "</p>");
    });
    $.ajax({
        context: ele,
        data: {
            html: "<img src='"+$e.data("imgsrc")+"' />",
            delay: Math.floor(Math.random()*5)
        }
    });
});