1. #1
    Sencha User Olivierco's Avatar
    Join Date
    Nov 2011
    Location
    Paris - France
    Posts
    65
    Vote Rating
    -1
    Answers
    3
    Olivierco is an unknown quantity at this point

      0  

    Default Answered: Submit form with no sucess

    Answered: Submit form with no sucess


    Hi,

    i have a form in my app to submit by mail:

    here the code of my button to submit my form:
    Code:
    {
    				xtype: 'button',
    				text: 'Envoyer ma réservation',
    				ui: 'confirm',
    				scope: this,
    				            handler: function (b, e) {
    				                var form = Ext.getCmp('reservation');
    				                form.submit({
    				                    url: 'app/view/formmail.php',
    				                    method: 'POST',
    				                    success: function (frm, res)  {
    				                        alert('Form submitted');
    				                    },
    				                    failure: function (frm, res) {
    				                        alert('Form no submit!');
    				                    }
    				                });
    				            }
    			}
    the formmail.php

    Code:
    <?php 
    $TO = "contact@cirkles.fr"; 
    $subject = "Réservation Sofa"; 
    $h = "From: " . $TO; 
    $message = "Message:"; 
    while (list($key, $val) = each($HTTP_POST_VARS)) { 
    $message .= "$key : $val\n"; 
    } 
    mail($TO, $subject, $message, $h);
    ?>
    FYI, when i click on my button for submiting my mail, the mail is sent and i receive it well on my mailbox, the problem is :
    success: function (frm, res) {
    alert('Form submitted');
    },
    i have no success.

    once the mail is sent i would like to refresh my form and receive an alert for the user.

    can you help me please?

  2. You need to return some json:

    Code:
    {"success" : true}
    In PHP:

    Code:
    $result = array("success" => true);
    echo json_encode($result);

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,547
    Vote Rating
    872
    Answers
    3566
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    You need to return some json:

    Code:
    {"success" : true}
    In PHP:

    Code:
    $result = array("success" => true);
    echo json_encode($result);
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1