PDA

View Full Version : form.submit does not send headers



dottormichele
9 Sep 2015, 4:41 AM
Ext version tested:

Ext 4.2.1
Browser versions tested against:

FF,Chrome
Description:

form.submit does not send headers' info
Test Case:


form.submit({
url: 'myUrl.php,
submitEmptyText: false,
params : Ext.Object.merge({
datatype: 'Configuration_Save'
}, values),
headers: {
'test': 'fdihosd'
},
waitMsg: 'Loading data',
success: me.doOnSuccess,
scope: me
});

// Used to show the ajaxOptions' object
Ext.override(Ext.form.action.Submit, {
doSubmit: function() {
var me = this,
ajaxOptions = Ext.apply(me.createCallback(), {
url: me.getUrl(),
method: me.getMethod(),
headers: me.headers
});
var form = me.form,
jsonSubmit = me.jsonSubmit || form.jsonSubmit,
paramsProp = jsonSubmit ? 'jsonData' : 'params',
formEl, formInfo;


// For uploads we need to create an actual form that contains the file upload fields,
// and pass that to the ajax call so it can do its iframe-based submit method.
if (form.hasUpload()) {
formInfo = me.buildForm();
ajaxOptions.form = formInfo.formEl;
ajaxOptions.isUpload = true;
} else {
ajaxOptions[paramsProp] = me.getParams(jsonSubmit);
}


console.log(ajaxOptions);


Ext.Ajax.request(ajaxOptions);
if (formInfo) {
me.cleanup(formInfo);
}
}
});




console.log('ajaxOptions') show an object with headers
headers: {
'test': 'fdihosd'
}
but firebug does not show the headers in the request

bjdurham85
9 Sep 2015, 12:50 PM
While I'm not sure what the override you have included is meant for, perhaps move it above your form declaration?

Also, if you're using firebug forms are treated as an inline iframe and submitted so you won't see them in a console. Check your Net tab and look for the post there, does it have the headers when using that?


Regards,
Bryan

dottormichele
9 Sep 2015, 11:36 PM
Hi Bryan,


thank you for your reply.


I wrote the override code for debugging purpose to see what the ajaxOptions object contain. It was easiest to write the override code than modify the ext-all.js file. It will be executed when you press the send button in the form.


With "firebug does not show the headers in the request" I meant exactly what you wrote: the post request that you can see in the Net tab does not have the heades' info that I added.

Best regards.

bjdurham85
10 Sep 2015, 4:58 AM
In your app is the url correct and not missing a quote?


form.submit({
url: 'myUrl.php,

dottormichele
11 Sep 2015, 12:42 AM
yes, the url is missing a quote... but this is just a sample code to explain the problem and not the real code.

bjdurham85
11 Sep 2015, 6:35 AM
Thanks for the additional info.

Have you tested this specific scenario in a more recent release (currently 4.2.3)?

thuexetai123
12 Sep 2015, 12:22 AM
In your app is the url correct and not missing a quote?


form.submit({
url: 'myUrl.php,

omg, i missing it and not working, i will replace ... tks mod