1. #1
    Ext JS Premium Member
    Join Date
    Jan 2011
    Location
    NORWAY
    Posts
    106
    Vote Rating
    0
    frankbolviken is an unknown quantity at this point

      0  

    Question 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.

    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>
    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.

    Any ideas?

    Frank B

  2. #2
    Ext JS Premium Member
    Join Date
    Jan 2011
    Location
    NORWAY
    Posts
    106
    Vote Rating
    0
    frankbolviken is an unknown quantity at this point

      0  

    Default


    Btw, my formpanel is defined like this:

    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);
    	}
    });
    And submitcode:
    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');
    				}
    			});
    		}
    	}
    Anyone?

  3. #3
    Ext JS Premium Member
    Join Date
    Jan 2011
    Location
    NORWAY
    Posts
    106
    Vote Rating
    0
    frankbolviken is an unknown quantity at this point

      0  

    Default


    Seriously... nobody?

  4. #4
    Sencha User
    Join Date
    Jan 2008
    Posts
    46
    Vote Rating
    0
    theyang is on a distinguished road

      0  

    Default


    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.

  5. #5
    Sencha User
    Join Date
    Jan 2008
    Posts
    46
    Vote Rating
    0
    theyang is on a distinguished road

      0  

    Default


    Here is the solution from Ext forums in case anyone needs it:

    http://www.sencha.com/forum/showthre...response-type&

  6. #6
    Sencha User
    Join Date
    Apr 2010
    Location
    Salvador, Bahia, Brazil
    Posts
    1
    Vote Rating
    0
    vcardins is on a distinguished road

      0  

    Default 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:
    Code:
    Ext.each([/<\/?pre[^>]*>/g, /<\/?embed[^>]*>/g], function (s) {            
        json = json.replace(s, "");
    });
    to Ext.JSON decode method, it removes the
    HTML Code:
    pre
    and
    HTML Code:
    embed
    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?

  7. #7
    Sencha User nbabinski's Avatar
    Join Date
    Apr 2011
    Location
    Ukraine, Kyiv
    Posts
    21
    Vote Rating
    2
    nbabinski is on a distinguished road

      0  

    Default


    for versions 4.* the same is going in the 3rd series
    http://docs.sencha.com/ext-js/4-1/#!...thod-hasUpload

    The 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.
    content-type should be set to text/html

Similar Threads

  1. TreePanel error: An invalid or illegal string was specified code: 12
    By forumuser1080 in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 15 Feb 2011, 7:53 AM
  2. Replies: 0
    Last Post: 6 Jul 2010, 6:11 AM
  3. Replies: 6
    Last Post: 17 Aug 2009, 12:49 PM
  4. [Ext 2.0 beta1] - invalid or illegal string was specified
    By pongz79 in forum Ext 2.x: Help & Discussion
    Replies: 6
    Last Post: 30 Nov 2007, 9:15 AM

Thread Participants: 3

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi