-
10 May 2011 12:24 AM #1
Fileupload - Invalid JSON string
Fileupload - Invalid JSON string
Hi,
I'm currently trying to implement a fileupload function for my application. The upload itself works fine, but in the callback (or something), I get the following error in my console.
I dont understand why these "<pre>" tags have been added to my response. I've read that the browser can add it, but not quite understood why.You're trying to decode and invalid JSON String: <pre style="word-wrap: break-word; white-space: pre-wrap;">{
"nodeRef": "workspace://SpacesStore/2300de2d-050f-4d01-a10c-1bec157ce8cb",
"fileName": "Alfresco som repository for Darwin.docx",
"status":
{
"code": 200,
"name": "OK",
"description": "File uploaded successfully"
}
}
</pre>
Any ideas?
Frank B
-
10 May 2011 2:35 AM #2
Btw, my formpanel is defined like this:
And submitcode:Code:Ext.define('app.view.NewFile', { alias: 'widget.newfile', extend: 'Ext.Window', title: 'Last opp fil', modal: true, width: 500, layout: 'fit', initComponent: function() { this.formPanel = Ext.create('Ext.form.Panel', { fileUpload: true, bodyStyle:'padding:5px 5px 0', border: false, items: [{ xtype: 'textfield', name: 'filename', autoHeight: true, allowBlank: false, fieldLabel: 'Navn', blankText: 'Navn' }, { xtype: 'textfield', name: 'destination', autoHeight: true, allowBlank: false, fieldLabel: 'Container', blankText: 'Container' },{ xtype: 'filefield', emptyText: 'Velg fil..', fieldLabel: 'Fil', name: 'filedata', width: 400, buttonText: 'Velg' }], buttons: [{ text: 'Lagre', action: 'save' }] }); this.items = [this.formPanel], this.callParent(arguments); } });
Anyone?Code:createFile : function(button) { var window = button.up('window'); var form = window.down('form').getForm(); if(form.isValid()) { form.submit({ url: '/alfresco/service/api/upload' + '?alf_ticket=' + app.session, waitMsg: 'Laster oppe filene', success: function(form, action) { alert('yeah'); }, failure: function(form, action) { alert('feil'); } }); } }
-
19 May 2011 10:44 PM #3
Seriously... nobody?
-
26 May 2011 8:07 AM #4
Exactly the same problem here. If I submit the form with the file upload a Save As window comes up in Firefox. Please let me know if you find a solution.
-
26 May 2011 8:25 AM #5
Here is the solution from Ext forums in case anyone needs it:
http://www.sencha.com/forum/showthre...response-type&
-
5 May 2012 7:37 PM #6
I found a solution but it needs to add 2 lines to the ext core
I found a solution but it needs to add 2 lines to the ext core
By adding:
to Ext.JSON decode method, it removes theCode:Ext.each([/<\/?pre[^>]*>/g, /<\/?embed[^>]*>/g], function (s) { json = json.replace(s, ""); });andHTML Code:pre
tags from the returned JSON. I know it is not a good thing to change the core, but it worked. Any suggestions of how to apply the same and do not change Ext core?HTML Code:embed
-
15 Aug 2012 8:09 AM #7
for versions 4.* the same is going in the 3rd series
http://docs.sencha.com/ext-js/4-1/#!...thod-hasUpload
content-type should be set to text/htmlThe server response is parsed by the browser to create the document for the IFRAME. If the server is using JSON to send the return object, then the Content-Type header must be set to "text/html" in order to tell the browser to insert the text unchanged into the document body.
Similar Threads
-
TreePanel error: An invalid or illegal string was specified code: 12
By forumuser1080 in forum Ext 3.x: Help & DiscussionReplies: 2Last Post: 15 Feb 2011, 7:53 AM -
Microsoft JScript runtime error: Sys.ArgumentException: The format string is invalid.
By Dalorzo in forum Ext 3.x: Help & DiscussionReplies: 0Last Post: 6 Jul 2010, 6:11 AM -
[UNKNOWN][3.0.0] Ext.util.JSON.decode(string json, function reviver)
By joeutz in forum Ext 3.x: BugsReplies: 6Last Post: 17 Aug 2009, 12:49 PM -
[Ext 2.0 beta1] - invalid or illegal string was specified
By pongz79 in forum Ext 2.x: Help & DiscussionReplies: 6Last Post: 30 Nov 2007, 9:15 AM


Reply With Quote