title: Post login form in Sencha Touch
body: <p>I want to login to an external site (not my own) using Sencha Touch. </p>
  
  <p>Here's some of my code:</p>
  
  <p><strong>Login controller</strong></p>
  
  <pre><code>Ext.define('Myapp.controller.Login', {
  extend: 'Ext.app.Controller',
  
  config: {
      refs: {
         loginForm: '#login-form'  
      },
      control: {
         '#login-button': {
            tap: 'onLoginHandler'
         } 
      }
  },
  
  onLoginHandler: function() {
    var form = this.getLoginForm();
    Ext.Ajax.request({
        url: 'https://www.site.com/login.html',
        headers: { 'Content-Type': 'application/x-www-form-urlencoded'},
        method: 'POST',
        params: form.getValues(),
        callback: function(options, success, response){
          console.log(options);
          console.log(response);
        }
    });
  }
  });
  </code></pre>
  
  <p><strong>Login view</strong></p>
  
  <pre><code>Ext.define('Myapp.view.Login', {
      extend: 'Ext.form.Panel',
      alias:  'widget.loginview',
      xtype: 'loginform',
      id: 'login-form',
      requires: [
          'Ext.form.FieldSet'
      ],
  
      config: {
          title: 'Log in',
          iconCls: 'user',
          html: 'Login View',
          method: 'POST',
          items: [ 
              {
                  xtype: 'fieldset',
                  title: 'Log in',
                  items: [ 
                      bunch of fields
                  ]
              },
          {
              xtype: 'button',
              text: 'Login',
              ui: 'action',
              id: 'login-button'
  
          } 
      ]
  }
  });
  </code></pre>
  
  <p>The result i see in my browser debugger is not what I'm expecting:</p>
  
  <pre><code>Request URL:https://www.site.com/login.html?_dc=1375705385394
  Request Headers
      Access-Control-Request-Headers:origin, x-requested-with, content-type
      Access-Control-Request-Method:POST
      Origin:http://localhost
      Referer:http://localhost/~me/non/
      User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36
  Query String Parameters URL encoded
      _dc:1375705385394
  </code></pre>
  
  <p>The form data isn't even there. But it shows up in the console.log from "console.log(response)" (see controller) so it should be sent</p>
  
  <p>The request module for node seems works as I want it to..</p>
  
  <pre><code>var request = require('request');
  var form = require('form-data');
  var r = request.post('https://www.site.com/login.html', function(err, resp, body){
  
  });
  
  var frm = r.form();
  frm.append(...// same fields as in my View, values are hardcoded for testing
  </code></pre>
  
  <p>The difference between these two is that the form is appended after the request...?</p>
  
  <p>Here's the headers when i login manually:</p>
  
  <pre><code>Request URL:https://www.site.com/login.html
  Request Method:POST
  Status Code:302 Found
  Request Headers
      Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/ *;q=0.8
      Accept-Encoding:gzip,deflate,sdch
      Accept-Language:en-US,en;q=0.8,sv;q=0.6
      Cache-Control:max-age=0
      Connection:keep-alive
      Content-Length:53
      Content-Type:application/x-www-form-urlencoded
      Cookie:NOW=4b21bf97818dd91f28732aec2b12344e28ac4aef; TUX-COOKIE=R2414511234; /=; /firsttimeload=0; s_cc=true; s_sq=%5B%5BB%5D%5D
      Host:www.site.com
      Origin:https://www.site.com
      Referer:https://www.site.com/
      User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36
  Form Data URL encoded
      ...my secret form data shows up here
  Response Headersview source
      Connection:Keep-Alive
      Content-Encoding:gzip
      Content-Length:184
      Content-Type:text/html; charset=iso-8859-1
      Date:Mon, 05 Aug 2013 12:57:09 GMT
      Keep-Alive:timeout=5, max=100
      Location:../redirect/location
      Server:Apache
      Set-Cookie:TUX-COOKIE=R2414511234; path=/
      Set-Cookie:NOW=none; path=/; expires=Fri, 08-Aug-2003 12:57:09 GMT; secure
      Set-Cookie:NOW=e555573f3e21a1f008f4be34c7c61234b1014b6; path=/; secure
      Vary:Accept-Encoding,User-Agent
  </code></pre>
  
  <p>Any thoughts or ideas are welcome! THANKS!</p>