Search code examples
jsonextjssencha-touchsencha-touch-2

Post Raw Json via .submit()


How can I post username/password as Raw JSON via form.submit().

loginForm.submit({  
    url: 'localhost/login',
    method: 'post',
    jsonData: loginForm.getValues()
...
    success: ...

even with Ext.JSON.encode(loginForm.getValues()) server is receiving as username=test&password=test which I need to be {"username":"test","password":"test"}


Solution

  • You should probably try something like

    Ext.Ajax.request({
        method: 'POST',
        url: 'submit.php',
        params  : {
            data: Ext.encode(loginForm.getValues())
        },
        success: function() {
        },
        failure: function() {
        }
    });
    

    Source for reference