Bug Tracker

Opened 12 years ago

Closed 12 years ago

#2110 closed bug (worksforme)

jsonp script elements are never removed

Reported by: malsup Owned by:
Priority: major Milestone: 1.2.2
Component: ajax Version: 1.2.1
Keywords: Cc:
Blocked by: Blocking:

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?

Change History (1)

comment:1 Changed 12 years ago by john

Component: coreajax
Resolution: worksforme
Status: newclosed

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.