1. #1
    Ext User
    Join Date
    Dec 2007
    Posts
    279
    Vote Rating
    0
    marco76 is on a distinguished road

      0  

    Default Problem on submit form

    Problem on submit form


    Hi
    I would make a try to submit a simple form using ext 2.0.
    My code is this:

    HTML Code:
      
    Ext.onReady(function(){
    Ext.QuickTips.init();
     
     
     var SubmitLogin = function() {
    	var s=simple.form.submit({        
            failure: function() {
              Ext.MessageBox.alert('Status', 'Error');
            },
            success: function() {
              Ext.MessageBox.alert('Status', 'Success');
            }
          });
      };
    
        var simple = new Ext.FormPanel({
    	labelWidth: 75, // label settings here cascade unless overridden
    	url:'prova.php',
    	method: 'POST',
    	title: 'Simple Form',
    	bodyStyle:'padding:5px 5px 0',
    	width: 350,
    	defaults: {width: 230},
    	defaultType: 'textfield',
    
            items: [{
                    fieldLabel: 'First Name',
                    name: 'first'
                }],
    
            buttons: [{
                text: 'Save',
    	    handler: SubmitLogin
            },{
                text: 'Cancel'
            }]
        });
    
       simple.render(document.body);
     
    });

    My prova.php is

    PHP Code:
    <? print_r($_POST[]); ?>
    But I get always an error.
    With Firebug I get this error :"missing ) in parenthetical
    ext-all-debug.js (line 6761)"

    Can someone tell me what that means?
    Many Thanks
    MArco

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    89
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    A BasicForm submit expects a JSON response with a success property.

  3. #3
    Ext User
    Join Date
    Dec 2007
    Posts
    279
    Vote Rating
    0
    marco76 is on a distinguished road

      0  

    Default


    Can me make an example ?
    Can you change my code with the right solution?

  4. #4
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    89
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    You can find an example here.

  5. #5
    Ext User
    Join Date
    Dec 2007
    Posts
    279
    Vote Rating
    0
    marco76 is on a distinguished road

      0  

    Default


    Sorry but from this example I can't to know I must change my code.
    Have I to change the response of my server ?
    Have I to change my JS script?
    What have I to do?

  6. #6
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    89
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    I'm not a PHP programmer so I can't really help you here, but to start you off:

    Replace prova.php with:

    PHP Code:
    {success:true

  7. #7
    Ext User cerad's Avatar
    Join Date
    Dec 2007
    Posts
    226
    Vote Rating
    0
    cerad is on a distinguished road

      0  

    Default


    PHP Code:
    // prova.php
    $data = array('success' => true);
    echo 
    json_encode($data); 
    Use firebug to confirm the request is being sent and received.

Thread Participants: 2