您好我正在尝试使用Jquery文件上传。我已经在FireFox和Chrome上正常工作了。像往常一样,IE必须脱颖而出,发脾气,让我们的生活更有趣。当我点击上传按钮时,我收到此错误。有没有人遇到过这个错误以及有关其发生原因的任何建议?
SCRIPT438:对象不支持属性或方法'find' jquery.ui.widget.js,第479行第3期
我在IE9中遇到问题。我认为同样的问题也出现在IE7和IE8中。
这是一段代码。
而不是Jquery模板我在这里使用JSRender,但它不应该产生很大的不同,因为我正在使用我自己的回调。
var oXHR = {};
var iUpload =1;
$(document).ready(function() {
// Stuff to do as soon as the DOM is ready;
'use strict';
// Initialize the jQuery File Upload widget:
$('#fileupload').fileupload({
// Uncomment the following to send cross-domain cookies:
//xhrFields: {withCredentials: true},
dataType: 'json',
url: filepath,
formData: data,
dropZone: $('#dropcontainer'),
fileInput: $('input:file'),
add: function(e, data) {
$('#fileslist').prepend($.render([{ ID: 'upload'+iUpload, NAME: data.files[0].name, SIZE: data.files[0].size }], 'fileUploadTemplate'));
data.context = 'upload'+iUpload;
oXHR['upload'+iUpload] = data;
iUpload++;
},
progress: function(e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10)/100;
$('#filespending'+data.context).css('backgroundPosition',-350+(350*progress));
},
done: function(e, data) {
var filedata = jQuery.parseJSON(data.jqXHR.responseText);
console.log(filedata)
if(filedata.STATUS){
$('#filespending'+data.context).remove();
$('#fileslist').prepend($.render([{ FILEID: filedata.VALUE.FILEID, NAME: filedata.VALUE.NAME, SIZE: filedata.VALUE.FILESIZE,DATEMODIFIED:filedata.VALUE.DATEMODIFIED }], 'fileListTemplate'));
}
else{
$('#filespending'+data.context).addClass('erroruploadingfile');
}
},
start: function(e){
console.log('start')
console.log(JSON.stringify(e))
}
});
// Enable iframe cross-domain access via redirect option:
$('#fileupload').fileupload(
'option',
'redirect',
window.location.href.replace(
/\/[^\/]*$/,
'/cors/result.html?%s'
)
);
$('#fileupload').unbind();
$('#fileupload').click(function(){
var i = 1;
$.each(oXHR, function(key, value) {
console.log(JSON.stringify(oXHR[key]))
oXHR[key] = oXHR[key].submit();
i++;
if(i == iUpload) {
iUpload = 1;
oXHR = {};
}
});
});
// Show feedback on dragover
$(document).bind('dragover', function(e) {
var dropZone = $('#dropcontainer'),
timeout = window.dropZoneTimeout;
if(timeout) {
clearTimeout(timeout);
}
if(e.target === dropZone[0]) {
dropZone.addClass('containerdroppable');
} else {
dropZone.removeClass('containerdroppable');
}
window.dropZoneTimeout = setTimeout(function () {
window.dropZoneTimeout = null;
dropZone.removeClass('containerdroppable');
}, 100);
});
$(document).bind('drop dragover', function (e) {
e.preventDefault();
});
});
我也在使用jQuery UI Widget 1.9.1 + amd