Results 1 to 3 of 3

Thread: config to default all request methods in app to POST?

  1. #1
    Sencha User
    Join Date
    Dec 2013
    Posts
    52
    Answers
    1

    Default config to default all request methods in app to POST?

    I was thinking there might be some config like in Ext.application for example that might default all requests to POST. But i cant seem to find a config that can do this. Is there an easy way to default all requests in my app to POST?

    Thanks

  2. #2
    Sencha User
    Join Date
    Mar 2012
    Location
    Lawrence, KS
    Posts
    462
    Answers
    65

    Default

    You could define a base class and extend Ext.data.Connection. Then add the post method to your base class. Then you can use that class instead of Ext.ajax.Request. For example:

    Code:
    Ext.define('Fiddle.Ajax', {
        extend: 'Ext.data.Connection',
        singleton: true,
        url: 'fake.php',
        method: 'POST'
    });
    
    
    Fiddle.Ajax.request({
        params: {
            foo: 'bar'
        }
    });

  3. #3
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791
    Answers
    585

    Default

    The question is quite open-ended as you haven't specified what you mean by 'default'.

    Greg's suggestion works fine if you're just concerned with direct calls to request but it won't affect proxies. You could alternatively set Ext.Ajax.method = 'POST' (again, proxies explicitly set their method so won't be affected).

    Something like this would force all requests to use POST, something much stronger than a 'default':

    Code:
    Ext.Ajax.on('beforerequest', function(conn, options) {
        options.method = 'POST';
    });
    Last edited by skirtle; 16 Jul 2014 at 10:25 PM. Reason: Address potential ambiguity

Posting Permissions

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