Commit 1ad874f3 authored by jaubourg's avatar jaubourg Committed by Dave Methvin

Further script transport cleanup, close gh-1123.

parent c373a499
...@@ -25,30 +25,27 @@ jQuery.ajaxPrefilter( "script", function( s ) { ...@@ -25,30 +25,27 @@ jQuery.ajaxPrefilter( "script", function( s ) {
}); });
// Bind script tag hack transport // Bind script tag hack transport
jQuery.ajaxTransport( "script", function(s) { jQuery.ajaxTransport( "script", function( s ) {
// This transport only deals with cross domain requests // This transport only deals with cross domain requests
if ( s.crossDomain ) { if ( s.crossDomain ) {
var callback; var script, callback;
return { return {
send: function( _, complete ) { send: function( _, complete ) {
callback = function( type ) { script = jQuery("<script>").prop({
return function() {
callback = script.onload = script.onerror = null;
jQuery( script ).remove();
if ( type ) {
complete( type === "success" ? 200 : 404, type );
}
};
};
var script = jQuery.extend( document.createElement("script"), {
async: true, async: true,
charset: s.scriptCharset, charset: s.scriptCharset,
src: s.url, src: s.url
onload: callback("success"), }).on(
onerror: callback("error") "load error",
}); callback = function( evt ) {
callback = callback(); script.off().remove();
document.head.appendChild( script ); callback = null;
if ( evt ) {
complete( evt.type === "error" ? 404 : 200, evt.type );
}
}
);
document.head.appendChild( script[ 0 ] );
}, },
abort: function() { abort: function() {
if ( callback ) { if ( callback ) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment