Results 1 to 7 of 7

Thread: How to force "post" method in Ajax.request

  1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    6

    Default How to force "post" method in Ajax.request

    Hi everybody,

    I'm newbie to Extjs and can't make POST ajax requests work correctly. Whatever I try, like:
    Code:
                    Ext.Ajax.request({
                        method: 'POST',
                        params: {
                            x: csv_data,
                        },
                        success: function(result, request){
                        },
                        failure: function(result, request){
                        },
    requests are sent with GET method and I get the apache error "request failed: URI too long (longer than 8190)" if my csv_data is too long.

    Any help appreciated.

  2. #2
    Sencha User
    Join Date
    Oct 2011
    Posts
    6

    Default further deeper look in code

    I see in Ext.data.Connection.Override.js :
    Code:
                if (o.scriptTag || this.scriptTag || Ext.lib.Ajax.isCrossDomain(url)) {                this.transId = this.scriptRequest(method, url, cb, p, o); 
    
                } else { 
    
                   this.transId = Ext.lib.Ajax.request(method, url, cb, p, o);
    and scriptRequest overrides any method to GET:
    Code:
        scriptRequest : function(method, url, cb, data, options) {
    ...
            url += (url.indexOf("?") != -1 ? "&" : "?") + data + String.format("&{0}={1}", options.callbackParam || this.callbackParam || 'callback', trans.cb);
    Is this normal? How to transmit POST data in crossdomain situations?

  3. #3
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,392

    Default

    The only cross domain functionality will use GET
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  4. #4
    Sencha User
    Join Date
    Oct 2011
    Posts
    6

    Default need POST

    I absolutely need POST method. Will it work if I change code
    Code:
     if (o.scriptTag || this.scriptTag || Ext.lib.Ajax.isCrossDomain(url)) {                this.transId = this.scriptRequest(method, url, cb, p, o);               } else {                  this.transId = Ext.lib.Ajax.request(method, url, cb, p, o);
    with
    Code:
    this.transId = Ext.lib.Ajax.request(method, url, cb, p, o);
    ?

  5. #5
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,392

    Default

    Code:
    Ext.Ajax.request({
        method : 'POST',
        url    : 'something',
        params : {}
    });
    Will work but only same domain... Any cross-domain will not use POST
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  6. #6
    Sencha User
    Join Date
    Oct 2011
    Posts
    6

    Default

    You are telling me that there is no way to send a POST Ajax request upon cross domains ?!
    Is there a reason to that ?

  7. #7
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,392

    Default

    Quote Originally Posted by kmchen13 View Post
    You are telling me that there is no way to send a POST Ajax request upon cross domains ?!
    Is there a reason to that ?
    It's browser security not to allow cross-origin Ajax requests. The way it is done is adding a script tag with the url you are sending the request as the src which the browser will only send as GET.

    You may want to look into CORS to see if you can get that running.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

Tags for this Thread

Posting Permissions

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