With this (jquery for fileupload) script I receive some error, but it's working in wamp in local. For production I need to stop this alert error"
"SyntaxError: missing } after property list
progressall: function (e, data) {"
or in Chrome:
"uncaught syntaxerror unexpected identifier on line 211"
The same line as in firefox.
Does anybody have an idea?
$(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.');
}
});
});
I made few modifications: no error in mozilla but not working
In chrome error (Uncaught TypeError: Cannot call method 'push' of undefined ) and not working
$(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);
});
The Correct script with a syntax error
SyntaxError: missing } after property list
filesContainer: $('.filescontainer')
And I don't ever need filesContainer because I retrieve a second jquery tab with uploadsystem
$(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')
});
});