Results 1 to 3 of 3

Thread: Form submit doesn't callback success

  1. #1
    Touch Premium Member
    Join Date
    May 2011
    Posts
    38

    Question Form submit doesn't callback success

    So I was trying to figure out why my FormPanel does not execute the success callback.
    here is a quick example:

    Code:
    f = new Ext.form.FormPanel({
      url: 'server/script'
      items: [
        {
        xtype: 'textfield',
        name : 'name',
        label: 'name'
        },
      ],
    });
    
    f.submit({
      success: function() {
        console.log('success'); // this doesnt get called
      },
      failure: function() {
        console.log('failure'); // this gets called
      }
    });
    I have the server script return text in json format. After some hair pulling and looking at the source code for FormPanel in sencha-touch-debug.js:26579. I see this

    Code:
    response = Ext.decode(responseText);
    success = !!response.success;
    Why does it look for success from the responseText? This means that the server side script needs to always send the response in this format

    Code:
    {
      success: true,
      responseData: [...]
    }
    Can't we use HTTP status for success or failure?

  2. #2
    Sencha User bclinton's Avatar
    Join Date
    Nov 2007
    Posts
    305

    Default

    If you read the comments in FormPanel.submit in the API docs, it says:
    success : Function
    The callback that will be invoked after a successful response. A response is successful if a response is received from the server and is a JSON object where the success property is set to true, {"success": true}
    It will probably be easiest to structure your server responses with the success property, but of course you could always override the submit method of FormPanel and put your own test in there.

  3. #3
    Touch Premium Member
    Join Date
    May 2011
    Posts
    38

    Default

    thanks for pointing that out, I guess it was my fault for not reading the documentation but it's kinda strange implementation.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •