Error message: "Unable to parse server response"
Added by Jay Gridley 10 months ago
I am getting this response even when file is succesfully uploaded (shown after reload) after hitting upload button. JSON response for HTML query sended from upload box is:
{"select":["0e31f397ab786744b4c9fcd5468535c9"],"debug":{"_isUploadAllow":{"1308939040_home_64.png":"unknown"}},"cwd":{"hash":"7a2adad0f7faea9ab2d9c871e9792538","name":"V\u00fdchoz\u00ed","mime":"directory","rel":"V\u00fdchoz\u00ed","size":0,"date":"8. 07. 2011 13:54","read":true,"write":true,"rm":false},"tmb":true,"cdc":[{"name":"1308939040_home_64.png","hash":"0e31f397ab786744b4c9fcd5468535c9","mime":"image\/png","date":"Today 13:54","size":6704,"read":true,"write":true,"rm":true,"url":"http:\/\/localhost\/NetteCMS.SVN\/trunk\/public\/files\/1308939040_home_64.png","dim":"64x64","resize":true}]}
Is there any unparseable part?
Replies (6)
RE: Error message: "Unable to parse server response"
-
Added by Oldřich Válek 9 months ago
Same problem here. Files are succesfully uploaded (shown after "manually" reload). It is hapening in all browsers. I don't care about the error messages, so i just want to reload elfinder directly after upload. I am not very interested in elfinder or javascript, so is there any way to do that? I found in "elfinder.js" function for upload. Maybe there i should add something, but i dont know, what it should be.
Thanks for help and sorry for my bad english.
RE: Error message: "Unable to parse server response"
-
Added by Troex Nevelin 9 months ago
Does it happens on demo? If not than probably an issue on your server side.
RE: Error message: "Unable to parse server response"
-
Added by Oldřich Válek 9 months ago
I think too, that is a strange problem on my server side, but files are uploaded succesfully, just with that error message... So is there any way how to reload elfinder automatically, after upload? Becouse like i sad, new uploaded files won't show up, until i click reload.
Thanks for answer.
RE: Error message: "Unable to parse server response"
-
Added by Troex Nevelin 9 months ago
elfinder does automatic reload successful uploadб but on fail, I think there is no way to force the reload on fail without editing the source code
RE: Error message: "Unable to parse server response"
-
Added by Oldřich Válek 9 months ago
How to call function "reload" in this code?
upload : function(fm) {
var self = this;
this.name = 'Upload files';
this.fm = fm;
this.exec = function() {
var id = 'el-finder-io-'+(new Date().getTime()),
e = $('<div class="ui-state-error ui-corner-all"><span class="ui-icon ui-icon-alert"/><div/></div>'),
m = this.fm.params.uplMaxSize ? '<p>'+this.fm.i18n('Maximum allowed files size')+': '+this.fm.params.uplMaxSize+'</p>' : '',
b = $('<p class="el-finder-add-field"><span class="ui-state-default ui-corner-all"><em class="ui-icon ui-icon-circle-plus"/></span>'+this.fm.i18n('Add field')+'</p>')
.click(function() { $(this).before('<p><input type="file" name="upload[]"/></p>'); }),
f = '<form method="post" enctype="multipart/form-data" action="'+self.fm.options.url+'" target="'+id+'"><input type="hidden" name="cmd" value="upload" /><input type="hidden" name="current" value="'+self.fm.cwd.hash+'" />',
d = $('<div/>'),
i = 3;
while (i--) { f += '<p><input type="file" name="upload[]"/></p>'; }
// Rails csrf meta tag (for XSS protection), see #256
var rails_csrf_token = $('meta[name=csrf-token]').attr('content');
var rails_csrf_param = $('meta[name=csrf-param]').attr('content');
if (rails_csrf_param != null && rails_csrf_token != null) {
f += '<input name="'+rails_csrf_param+'" value="'+rails_csrf_token+'" type="hidden" />';
}
f = $(f+'</form>');
d.append(f.append(e.hide()).prepend(m).append(b)).dialog({
dialogClass : 'el-finder-dialog',
title : self.fm.i18n('Upload files'),
modal : true,
resizable : false,
close : function() { self.fm.lockShortcuts(); },
buttons : {
Cancel : function() { $(this).dialog('close'); },
Ok : function() {
if (!$(':file[value]', f).length) {
return error(self.fm.i18n('Select at least one file to upload'));
}
setTimeout(function() {
self.fm.lock();
if ($.browser.safari) {
$.ajax({
url : self.fm.options.url,
data : {cmd : 'ping'},
error : submit,
success : submit
});
} else {
submit();
}
});
$(this).dialog('close');
}
}
});
self.fm.lockShortcuts(true);
function error(err) {
e.show().find('div').empty().text(err);
}
function submit() {
var $io = $('<iframe name="'+id+'" name="'+id+'" src="about:blank"/>'),
io = $io[0],
cnt = 50,
doc, html, data;
$io.css({ position: 'absolute', top: '-1000px', left: '-1000px' })
.appendTo('body').bind('load', function() {
$io.unbind('load');
result();
});
self.fm.lock(true);
f.submit();
function result() {
try {
doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;
/* opera */
if (doc.body == null || doc.body.innerHTML == '') {
if (--cnt) {
return setTimeout(result, 100);
} else {
complite();
return self.fm.view.error('Unable to access iframe DOM after 50 tries');
}
}
/* get server response */
html = $(doc.body).html();
if (self.fm.jquery>=141) {
data = $.parseJSON(html);
} else if ( /^[\],:{}\s]*$/.test(html.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@")
.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]")
.replace(/(?:^|:|,)(?:\s*\[)+/g, "")) ) {
/* get from jQuery 1.4 */
data = window.JSON && window.JSON.parse ? window.JSON.parse(html) : (new Function("return " + html))();
} else {
data = { error : 'Unable to parse server response' };
}
} catch(e) {
data = { error : 'Unable to parse server response' };
}
complite();
data.error && self.fm.view.error(data.error, data.errorData);
data.cwd && self.fm.reload(data);
data.tmb && self.fm.tmb();
}
function complite() {
self.fm.lock();
$io.remove();
}
}
}
this.isAllowed = function() {
return this.fm.cwd.write;
}
this.cm = function(t) {
return t == 'cwd';
}
},
RE: Error message: "Unable to parse server response"
-
Added by Marcin Lewandowski 4 months ago
Jay Gridley wrote:
I am getting this response even when file is succesfully uploaded (shown after reload) after hitting upload button. JSON response for HTML query sended from upload box is:
[...]
Is there any unparseable part?
I have the same problem, but i checked what is variable to content in html
/* get server response */ html = $(doc.body).html();
This content is wrong, becouse on the begining, and at the end of this content i have :
(1-6/6)