1. #1
    Sencha User
    Join Date
    Aug 2012
    Posts
    2
    Vote Rating
    0
    spiteful_troll is on a distinguished road

      0  

    Default Unanswered: Ext.Ajax.request, JSON is not POST

    Unanswered: Ext.Ajax.request, JSON is not POST


    Hello.
    I want to update my ExtJS grid using Ext.form.FormPanel.
    Unfortunately my form doesn't update the grid.
    This is the code I send data from the FormPanel:

    Code:
    handler: function() {
                var form = this.up('form').getForm();
                var formData = Ext.encode(form.getValues());                                         
                var received = function (response) {
                x = Ext.decode( response.responseText );
                console.log(this);
             }
    
              Ext.Ajax.request({
                    url: '/ajax/index/extjsaction/update',
                    method: 'POST',          
                    headers: {'Content-Type': 'text/html'},
                    waitTitle: 'Connecting',
                    waitMsg: 'Sending data...',                                     
                    jsonData: {
                           sectors: formData                                    
                    },
                    success: received,                                    
                    failure: function(){console.log('failure');}
      });
    After submitting In console I can see and It doesn't update the grid:

    POST tab:
    Code:
    JSON
     sectors "{\"sectorid\":\"12\",\"sectorbg\":\"ico43\",\"lastactualizedate\":\"2012-06-20\",\"picture\":\"c14b9d287a06bcb9eeba23b153bbb6fd.png\",\"dispno\":\"12\",\"site_link\":\"\",\"target_blank\":\"13\"}"
    When I update the grid using Ext.grid.plugin.CellEditing my POST data looks another and it works:

    POST tab:
    Code:
    Parameters application/x-www-form-urlencoded
    sectors {"sectorid":12,"sectorbg":"ico48","lastactualizedate":"2012-06-20","picture":"c14b9d287a06bcb9eeba23b153bbb6fd.png","dispno":12,"site_link":"","target_blank":1,"id":null}
    My proxy code:

    Code:
    var store = new Ext.data.Store({
            autoLoad: true,
            autoSync: false, // указание на автосохранения в хранилище
            model: 'Sectors',
            pageSize: 10, // ОБЯЗАТЕЛЬНО В ХРАНИЛИЩЕ store!!!
            remoteSort: true,
            disableCaching : true,
            proxy: {
                type: 'ajax',
                api: {
                    read: '/ajax/index/extjsaction/read',
                    update: '/ajax/index/extjsaction/update',
                    create: '/ajax/index/extjsaction/create',
                    destroy: '/ajax/index/extjsaction/destroy'
                },
                reader: {
                    type: 'json',
                    root: 'sectors',
                    totalProperty: 'total'
                },
                writer: {
                    type: 'json',
                    root: 'sectors',
                    totalProperty: 'total',
                    encode: true
                }
            }
        });
    Please help. I am new in ExtJS and I think I lost some important detail here.
    Last edited by spiteful_troll; 9 Sep 2012 at 11:58 PM. Reason: I made the code more readable

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,828
    Answers
    453
    Vote Rating
    609
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Moved to QA.

    You shouldn't encode the jsonData, the request will already do that for you.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Sencha User
    Join Date
    Aug 2012
    Posts
    2
    Vote Rating
    0
    spiteful_troll is on a distinguished road

      0  

    Default


    I tried do use it without json encoding:

    Code:
    Ext.Ajax.request({
          url: '/ajax/index/extjsaction/update',
          method: 'POST',
           headers: {'Content-Type': 'text/html'},
           waitTitle: 'Connecting',
           waitMsg: 'Sending data...',
           jsonData: {
                  sectors: form.getValues()
           },
           success: received,                                    
           failure: function(){console.log('failure');}   
    });
    Anyway it returns:
    Code:
    JSON
           
    sectors
        Object { sectorid="11", sectorbg="Test23", lastactualizedate="2012-06-20", more...}
    But I need data like my grid returns:
    Code:
    POST Parameters application/x-www-form-urlencoded
    sectors    {"sectorid":12,"sectorbg":"ico48","lastactualizedate":"2012-06-20","picture":"c14b9d287a06bcb9eeba23b153bbb6fd.png","dispno":12,"site_link":"","target_blank":1,"id":null}

Thread Participants: 1

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