1. #1
    Sencha User
    Join Date
    May 2011
    Posts
    9
    Vote Rating
    0
    luks35 is on a distinguished road

      0  

    Default ExtJS 3.4 + JSON + PHP request and response

    ExtJS 3.4 + JSON + PHP request and response


    Sory about my english... but I'll try
    How can I send request and respons from ExtJS 3.4 with formul and response via PHP JSON?

  2. #2
    Sencha User
    Join Date
    Oct 2010
    Posts
    107
    Vote Rating
    0
    boston-george is on a distinguished road

      0  

    Default


    try this:

    Code:
    Ext.Ajax.request({
    url: '/login/login',
    params:{
    user: Ext.getCmp('ioUser').getValue(),
    pass: Ext.getCmp('ioPwd').getValue() },
    method:'POST', success: function(result, request){
    var res = new Object();
    res = Ext.util.JSON.decode(result.responseText); if(res.login == false){ Ext.MessageBox.alert('Warning',res.message);
    }else{ location.href = '/main/index' }
    }
    });

  3. #3
    Sencha User
    Join Date
    May 2011
    Posts
    9
    Vote Rating
    0
    luks35 is on a distinguished road

      0  

    Default


    I dont know how use this
    hellp

  4. #4
    Sencha User
    Join Date
    Jan 2008
    Location
    Maryville, IL, US
    Posts
    288
    Vote Rating
    0
    httpdotcom is on a distinguished road

      0  

    Default


    It's a simple example of an Ext.Ajax.request() submitting to a PHP page and processing the JSON response.

    If you were after something specific, you need to be more specific about your request.

  5. #5
    Sencha User
    Join Date
    May 2011
    Posts
    9
    Vote Rating
    0
    luks35 is on a distinguished road

      0  

    Default


    PHP Code:
    var obj1 Ext.PanelFormid'formObj1', ....);

    Ext.getCmp('formObj1').getForm().submit({
        
    clientValidationtrue,
        
    method'POST',
        
    url: ['serverPHP_extjsjson_url'], // <--- some url action
        
    params'data='+'{\"data\": '+Ext.encode(Ext.getCmp('formObj1').getForm().getValues())+'}',
        
    text'Updating...'// <--- to procesing whaiting
        
    success: function(formaction) {
            
    Ext.Msg.alert('Success'action.result.msg);
        },
        
    failure: function(formaction) { 
            switch (
    action.failureType) { 
                case 
    Ext.form.Action.CLIENT_INVALID
                
    Ext.Msg.alert('Failure''Form fields may  not be submitted with invalid values');
                break;

                case 
    Ext.form.Action.CONNECT_FAILURE
                
    Ext.Msg.alert('Failure''Ajax  communication failed'); 
                break; 

                case 
    Ext.form.Action.SERVER_INVALID
                
    Ext.Msg.alert('Failure'action.result.msg); 
            } 
        } 
    }); 
    This request sends data via a POST (the form) twice:
    - Once by submit
    - The second time in a compressed JSON format

    I want to send the data only by using JSON. How can I do?

  6. #6
    Sencha User
    Join Date
    Jan 2008
    Location
    Maryville, IL, US
    Posts
    288
    Vote Rating
    0
    httpdotcom is on a distinguished road

      0  

    Default


    Don't use the form.submit() method to "submit". Use Ext.Ajax.request(). That will prevent the double submission.

  7. #7
    Sencha User
    Join Date
    May 2011
    Posts
    9
    Vote Rating
    0
    luks35 is on a distinguished road

      0  

    Default


    when I use Ext.Ajax.request () is always a form will be sent without checking the validation and how I use form.submit () form will be checked whether the data have been introduced and if so, submit

  8. #8
    Sencha User
    Join Date
    Jan 2008
    Location
    Maryville, IL, US
    Posts
    288
    Vote Rating
    0
    httpdotcom is on a distinguished road

      0  

    Default


    Then you've got several options to choose from:
    1. Ext.override( Ext.form.FormPanel, submit: ... ) to submit a single JSON object, instead of an array of key/val pairs
    2. Ext.extend( Ext.form.FormPanel, submitJSON: ... ) to create a new submission routine for forms
    3. If ( form.isValid() ) Ext.Ajax.request( ... ) to validate the form prior to submitting
    4. Use submit() the way it was intended, and fix your PHP processor to accept POST/GET instead of a JSON object.

  9. #9
    Sencha User
    Join Date
    May 2011
    Posts
    9
    Vote Rating
    0
    luks35 is on a distinguished road

      0  

    Default


    4. Use submit() the way it was intended, and fix your PHP processor to accept POST/GET instead of a JSON object.
    How can I send it by POST in array? How can I send Array not each individual formul element?

    <input name="inp1">
    <input name="inp2">

    $_POST['myData'] = array('inp1' => 'value1', 'inp2' => 'value2');

  10. #10
    Sencha User
    Join Date
    Jan 2008
    Location
    Maryville, IL, US
    Posts
    288
    Vote Rating
    0
    httpdotcom is on a distinguished road

      0  

    Default


    You can't use Javascript/ExtJS to send a PHP array to a PHP processor, but you can process the $_POST array programmatically.

    However, doing that is a discussion for a different forum.

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