Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: AJAX call with large data as parameter

  1. #1

    Default AJAX call with large data as parameter

    Hi all,

    Any help on this one is appriciated. It might be simpel, I just don't know how :-)

    In my touch application I normally do AJAX calls this way:

    Code:
    Ext.util.JSONP.request({
        url: 'xhr/xhrHandover.asp',
        callbackKey: 'Ext.util.JSONP.callback',
        params: {
            cmd: 'savesignature',
            synid: me.synid,
            data: me.tp.canvas.toDataURL()
        },
        callback: function(data) {
        }
    });
    But in this case - where I try to pass the data from a canvas element I get an "414: Requested URI too long". How do I pass large data via AJAX using Ext Touch?

    Thanks in advance.

    - Thomas

  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258

    Default

    You don't use JSONP if you're sending data on the same domain. Just use an Ajax request, which will use POST.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  3. #3

    Default

    Thanks for the hint Evan. Don't know why I never used the Ext.Ajax.request, but I'm going there now... I do encounter one problem though. The JSON I return will not be decoded. It basically boild down to one simplified line of code:

    Code:
    var obj = Ext.decode('{ success: true, login: true }');
    which throws the error:

    ext-touch-debug.js:5530 - SyntaxError: Unable to parse JSON string

    Is this not the intent of the decode function??

  4. #4
    Sencha User hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,966

    Default

    You'll need this format

    Code:
    '{ "success": true, "login": true }'
    ..as Touch uses the browsers' internal JSON object for parsing.
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


  5. #5
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258

    Default

    jsonlint.com will be useful.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  6. #6
    Ext User
    Join Date
    Aug 2010
    Location
    Paris
    Posts
    24

    Default

    Is it possible to send date using POST with Sencha Touch ? How to do this ?

  7. #7
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258

    Default

    As I said above, just use an Ajax request with the params property. The data will be posted automatically.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  8. #8
    Ext User
    Join Date
    Aug 2010
    Location
    Paris
    Posts
    24

    Default

    Code:
    var formBase = {
                scroll: 'vertical',
                standardSubmit : false,
                items: [
                    {
                        xtype: 'fieldset',
                        defaults: {
                            required: true,
                            labelAlign: 'left'
                        },
                        items: [{
                            xtype: 'textfield',
                            name : 'name',
                            label: 'Nom',
                            autoCapitalize : false
                        }, {
                            xtype: 'passwordfield',
                            name : 'password',
                            label: 'Mot de passe'
                        }]
                    }
                ],
                listeners : {
                    submit : function(form, result){
                        //console.log('success', Ext.toArray(arguments));
                    },
                    exception : function(form, result){
                        //console.log('failure', Ext.toArray(arguments));
                    }
                },
    
                dockedItems: [
                    {
                        xtype: 'toolbar',
                        dock: 'bottom',
                        items: [
                            {
                                text: 'Vider les champs',
                                handler: function() {
                                    form.reset();
                                }
                            },
    			{xtype: 'spacer'},
                            {
                                text: 'Connexion',
                                ui: 'action',
                                handler: function(){
    							$.ajax({ 
    								dataType:'jsonp', 
    								type: 'POST',
    								url: 'http://www.***.com/***/***.php', 
    								data: { name: 'aa',
    										password: 'zz'
    									},
    								success:function(reponse) { 
    									//alert('plop');
    								}
    							}); 
    							}
    
                            }
                        ]
                    }
                ]
            };
    I try this, but the request seemed not to be sent to the another server.

  9. #9
    Ext User
    Join Date
    Aug 2010
    Location
    Paris
    Posts
    24

    Default

    And I tried this too but data aren't sent in POST :
    (I wrote with and without 'type=POST')
    Code:
    Ext.util.JSONP.request({
                    url: 'http://dev.***.com/***/***.php',
                    callbackKey: 'callback',
    		type:'POST',
                    params: {                    
                     name: 'aa',
    		password: 'zz'
                    },
                    callback: function(result) {
    					alert('ee');
                    }
                })

  10. #10
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258

    Default

    You can't send posts over JSONP, please read up on it: http://en.wikipedia.org/wiki/JSON#JSONP
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

Page 1 of 2 12 LastLast

Similar Threads

  1. AJAX Loading Large Trees
    By Limey in forum Ext 2.x: Help & Discussion
    Replies: 19
    Last Post: 18 Aug 2009, 10:15 AM
  2. Additional parameter for the PagingToolbar's async call
    By italianboy in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 17 Jun 2009, 6:17 AM
  3. Example of store and ajax call to retrive data
    By rikardq in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 25 Mar 2008, 12:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •