1. #1
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Mumbai, India
    Posts
    191
    Vote Rating
    0
    Answers
    10
    bomslang has a little shameless behaviour in the past

      0  

    Exclamation Unanswered: ExtJS form Submit

    Unanswered: ExtJS form Submit


    Hello,

    I have a ExtJS form with fields like below
    • Name Field ( Note : Multiple comma separated names are allowed )
    • Age Field
    • Email Field
    I want to submit this form values to the server side and notify the about the same (success or failure) to the email address provided in the email field i.e 3rd form field.

    Since there could be multiple names in the name field, I don't want to get multiple response for this single form submission.

    I don't want to send multiple form submission Ajax request.
    I want to submit the multiple names in a single Ext.Ajax.request() and then send a SINGLE notification to the email address value.

    How to achieve this ? How to correctly apply Ext.JSON.encode correctly ?
    e.g
    Code:
    var values = Ext.getCmp('myForm').getValues();
    
    Ext.Ajax.request({
       method : 'POST',
       url : ' ../../save.php',
       params: Ext.JSON.encode(values),// How to encode multiple name values here?
       success: function(response) {
              Ext.Msg.alert('Data submitted to all people');
       },
       failure : function(response) {
               Ext.Msg.alert('Error while submitting data to all people');
        }
    });
    Thanks

  2. #2
    Sencha - Community Support Team friend's Avatar
    Join Date
    Apr 2011
    Posts
    895
    Vote Rating
    27
    Answers
    106
    friend has a spectacular aura about friend has a spectacular aura about

      0  

    Default


    Ext.form.Panel has a built-in submit mechanism. Why not just use that? This will send discreet request parameters like name, age, and email. If should be a relatively simple matter to then parse the email request parameter using a comma as the delimiter.

  3. #3
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Mumbai, India
    Posts
    191
    Vote Rating
    0
    Answers
    10
    bomslang has a little shameless behaviour in the past

      0  

    Default


    Using form.submit() or Ext.Ajax.request() is not my question.

    e.g
    Name Field : Tom, Jerry, Mike
    ...
    Email Field : abc@gmail.com
    I want to pass all the names from the name field (i.e Tom, Jerry and Mike) in a single form submit Ajax request. I don't want to send multiple request for multiple names.

    I want a single response to be generated to email address of 'abc@gmail.com'

  4. #4
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,154
    Vote Rating
    475
    Answers
    685
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    If you have a single form, you will get a single submit.

    If a field has multiple names, then it will still be 1 string. You simple parse that field at the server level and generate a email for each and then send a single response back to the client.

    Scott.

  5. #5
    Sencha Premium Member
    Join Date
    Dec 2011
    Posts
    42
    Vote Rating
    9
    Answers
    1
    jcdang will become famous soon enough

      0  

    Default


    I believe by default it should be a string separated by comma.

    If it's not a string and instead an array, you can do this:

    values.name = value.join(',');

  6. #6
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Mumbai, India
    Posts
    191
    Vote Rating
    0
    Answers
    10
    bomslang has a little shameless behaviour in the past

      0  

    Default


    @Scott : Thank you for your reply.

    Let me clarify my question again.

    I have the above form fields already mentioned. When I click some submit button, I want to send an email notification to all those people at their respective email ids and then get back a single notification to abc@gmail.com that form data was successfully submitted to all those people individually at their email id.

    For the above problem statement, I need to send all the names in a single request.
    I am aware of sending one single value for textfield ( i.e here name field), but how to do it for multiple names which may be comma separated ?

    Is it achievable with your solution ?

  7. #7
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,154
    Vote Rating
    475
    Answers
    685
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    Yes .. this is like a distribution list ... you send 1 record to the server, the server would parse the field names (field id for each should be sent as param) and then send the emails and send a single record back for success/fail.

    The key is to send the id's to ensure that you get the right "John Smith" and to have the server process all of the records and send the emails.

    Scott.