jQuery: The Write Less, Do More JavaScript Library

Ticket #2110 (closed bug: worksforme)

Opened 8 months ago

Last modified 7 months ago

jsonp script elements are never removed

Reported by: malsup Assigned to: anonymous
Type: bug Priority: major
Milestone: 1.2.2 Component: ajax
Version: 1.2.1 Keywords:
Cc: Needs: Review

Description

Script elements accumulate when using jsonp. I could be missing something, but this block of code in $.ajax doesn't make sense to me:

// Handle Script loading
if ( !jsonp && (s.success || s.complete) ) {
    var done = false;
    // Attach handlers for all browsers
    script.onload = script.onreadystatechange = function(){
        if ( !done && (!this.readyState ||
                this.readyState == "loaded" || this.readyState == "complete") ) {
            done = true;
            success();
            complete();
            head.removeChild( script );
        }
    };
}

Why is removing the script element conditional on no jsonp and the presence of callbacks?

Attachments

Change History

Changed 7 months ago by john

  • status changed from new to closed
  • resolution set to worksforme
  • component changed from core to ajax

The problem is that if we remove the script before it's done processing, then the request won't complete. We have to wait until it's completed. I think you might be referring to another block of code that was causing problems, but this was resolved in 1.2.2.

Note: See TracTickets for help on using tickets.