用這個(jquery for fileupload)腳本我收到一些錯誤,但它在本地wamp中工作。對於生產我需要停止此警報錯誤」jquery fileupload語法錯誤類型錯誤
"SyntaxError: missing } after property list
progressall: function (e, data) {"
或在Chrome中:?
"uncaught syntaxerror unexpected identifier on line 211"
同線在Firefox
沒有任何人有一個想法
$(function() {
$('#fileupload').fileupload({
dataType: 'json',
done: function (e, data) {
$.each(data.result.files, function (index, file) {
$('<p/>').text(file.name).appendTo(document.body);
});
}
progressall: function (e, data) {
var progress = parseInt(data.loaded/data.total * 100, 10);
$('#progress .bar').css(
'width',
progress + '%'
);
}
add: function (e, data) {
data.context = $('<p/>').text('Uploading...').appendTo(document.body);
data.submit();
}
done: function (e, data) {
data.context.text('Upload finished.');
}
add: function (e, data) {
data.context = $('<button/>').text('Upload')
.appendTo(document.body)
.click(function() {
$(this).replaceWith($('<p/>').text('Uploading...'));
data.submit();
});
}
done: function (e, data) {
data.context.text('Upload finished.');
}
});
});
我做了一些修改: 在Mozilla中沒有錯誤,但沒有工作
在Chrome中的錯誤(遺漏的類型錯誤:無法調用未定義的「推」),而不是工作
$(function() {
//declare a "updloadOptions" variable object that will be passed to the plugin constructor method as a parameter. (You can give any name to this object.)
var updloadOptions = {};
//set the datatype property to 'json'.
updloadOptions.dataType = 'json';
//declare the "done" callback method on "updloadOptions" object.
updloadOptions.done = function (e, data) {
$.each(data.result.files, function (index, file) {
$('<p/>').text(file.name).appendTo(document.body);
});
};
//declare the "progressall" callback method on "updloadOptions" object.
updloadOptions.progressall = function (e, data) {
var progress = parseInt(data.loaded/data.total * 100, 10);
$('#progress .bar').css(
'width',
progress + '%');
};
//declare the "add" callback method on "updloadOptions" object.
updloadOptions.add = function (e, data) {
data.context = $('<button/>').text('Upload')
.appendTo(document.body)
.click(function() { $(this).replaceWith($('<p/>').text('Uploading...'));
data.context = $('<p/>').text('Uploading...').appendTo(document.body);
data.submit();
});
};
//initialize the component
$('#fileupload').fileupload(updloadOptions);
});
正確的腳本有語法錯誤
SyntaxError: missing } after property list
filesContainer: $('.filescontainer')
而且我從來沒有需要filesContainer
,因爲我檢索第二個jquery選項卡上傳系統
$(function() {
$('#fileupload').fileupload({
dataType: 'json',
done: function (e, data) {
$.each(data.result.files, function (index, file) {
$('<p/>').text(file.name).appendTo(document.body);
});
},
progressall: function (e, data) {
var progress = parseInt(data.loaded/data.total * 100, 10);
$('#progress .bar').css(
'width',
progress + '%'
);
},
add: function (e, data) {
data.context = $('<p/>').text('Uploading...').appendTo(document.body);
data.submit();
},
done: function (e, data) {
data.context.text('Upload finished.')
},
add: function (e, data) {
data.context = $('<button/>').text('Upload')
.appendTo(document.body)
.click(function() {
$(this).replaceWith($('<p/>').text('Uploading...'));
data.submit();
});
}, done: function (e, data) {
data.context.text('Upload finished.')
}
filesContainer: $('.filescontainer')
});
});
謝謝你的解釋是好,但實際上: 這是似乎更好的在Firefox上:沒有錯誤或警報,但插件不工作了 在Chrome中: 「Uncaught TypeError:無法調用未定義的方法'push'firebug-lite.js:30905 logRow firebug-lite.js:30905 logFormatted螢火-lite.js:30894 SYSOUT螢火-lite.js:30842個 CssAnalyzer.processAllStyleSheets螢火-lite.js:25751 FBL.Firebug.initialize螢火-lite.js:6289 (匿名功能)」 和不工作 所以我會測試... :-) – user1997147
我建議你使用帶有Firebug「擴展」的Firefox,直到你解決這個問題。並在此發佈完整的代碼,以便我們可以爲您提供更多幫助。在您發佈的代碼中沒有定義「推送」方法。但是,我在回答中提到的事情是你應該從頭開始的,因爲那個firebug-lite日誌不是你的代碼唯一的問題。 –
確定與Firefox沒有錯誤時加載頁面。圖片劑量不會出現,他們的名字進一步列出..當我點擊「添加文件」我已經得到了良好的eplorator,但點擊「打開」後,我得到了「DSC01461.JPG \t 2.88 MB \t Error SyntaxError:JSON.parse :意想不到的字符「.. – user1997147