Q:

On form.submit method add header issue

Submit method in my form to upload image and text fields 
Here is my code: 
var form = Ext.getCmp('form');
form.submit({
    url: webAPI+'setting/updateCityInformation',
    method: 'POST',
    headers: {
        token: getCookie("requestToken")
    },
    success: function(form, action) {
        console.log('success');
    },
    failure: function(form, action) {
    }
});

The token is not adding in this method please help me
Thanks in advance 

A:

Create a common function for all form submit methods:
Ext. Ajax.on("beforerequest", function(event, request) {
       if(request.headers && request.headers.token) {
            request.headers.token = getCookie("requestToken");
       }
});

