ajaxFileUpload 针对 ie jquery 1.7+不能使用问题修复版本
jQuery.extend({
handleError: function( s, xhr, status, e ) {
// If a local callback was specified, fire it
if ( s.error ) {
s.error.call( s.context || s, xhr, status, e );
}
// Fire the global callback
if ( s.global ) {
(s.context ? jQuery(s.context) : jQuery.event).trigger( "ajaxError", [xhr, s, e] );
}
},
createUploadIframe: function(id, uri)
{
var frameId = 'jUploadFrame' + id;
if(window.ActiveXObject) {
if(jQuery.browser.version=="9.0")
{
io = document.createElement('iframe');
io.id = frameId;
io.name = frameId;
}
else if(jQuery.browser.version=="6.0" || jQuery.browser.version=="7.0" || jQuery.browser.version=="8.0")
{
var io = document.createElement('<iframe id="' + frameId + '" name="' + frameId + '" />');
if(typeof uri== 'boolean'){
io.src = 'javascript:false';
}
else if(typeof uri== 'string'){
io.src = uri;
}
}
}
else {
var io = document.createElement('iframe');
io.id = frameId;
io.name = frameId;
}
io.style.position = 'absolute';
io.style.top = '-1000px';
io.style.left = '-1000px';
document.body.appendChild(io);
return io;
},
ajaxUpload:function(s,xml){
//if((fromFiles.nodeType&&!((fileList=fromFiles.files)&&fileList[0].name)))
var uid = new Date().getTime(),idIO='jUploadFrame'+uid,_this=this;
var jIO=$('<iframe name="'+idIO+'" id="'+idIO+'" style="display:none">').appendTo('body');
var jForm=$('<form action="'+s.url+'" target="'+idIO+'" method="post" enctype="multipart/form-data"></form>').appendTo('body');
var oldElement = $('#'+s.fileElementId);
var newElement = $(oldElement).clone();
$(oldElement).attr('id', 'jUploadFile'+uid);
$(oldElement).before(newElement);
$(oldElement).appendTo(jForm);
this.remove=function()
{
if(_this!==null)
{
jNewFile.before(jOldFile).remove();
jIO.remove();jForm.remove();
_this=null;
}
}
this.onLoad=function(){
var data=$(jIO[0].contentWindow.document.body).text();
try{
if(data!=undefined){
data = eval('(' + data + ')');
try {
if (s.success)
s.success(data, status);
// Fire the global callback
if(s.global)
jQuery.event.trigger("ajaxSuccess", [xml, s]);
if (s.complete)
s.complete(data, status);
xml = null;
} catch(e)
{
status = "error";
jQuery.handleError(s, xml, status, e);
}
// The request was completed
if(s.global)
jQuery.event.trigger( "ajaxComplete", [xml, s] );
// Handle the global AJAX counter
if (s.global && ! --jQuery.active )
jQuery.event.trigger("ajaxStop");
// Process result
}
}catch(ex){
alert(ex.message);
};
}
this.start=function(){jForm.submit();jIO.load(_this.onLoad);};
return this;
},
createUploadForm: function(id, url,fileElementId, data)
{
//create form
var formId = 'jUploadForm' + id;
var fileId = 'jUploadFile' + id;
var form = jQuery('<form action="'+url+'"