表单提交启用xhr2时会丢失所有表单数据
代码语言:javascript
复制form.submit({
xhr2: true
...
});
源码
代码语言:javascript
复制...
beforeAjaxSubmit: function(form, options, successFn, failureFn) {
...
if (Ext.feature.has.XHR2 && request.xhr2) {
delete request.form;
// 此处将表单值存入request.data有误,后续请求并没有从request.data取值
// 可通过override: 'Ext.form.Panel'覆盖此方法修订,改为:
// formData = request.rawData = new FormData(form);
formData = request.data = new FormData(form);
if (request.params) {
Ext.iterate(request.params, function(name, value) {
if (Ext.isArray(value)) {
Ext.each(value, function(v) {
formData.append(name, v);
});
}
else {
formData.append(name, value);
}
});
delete request.params;
}
}
...
}
...
代码语言:javascript
复制...
// 发起请求
request: function(options) {
...
// 装填请求信息
requestOptions = me.setOptions(options, options.scope || Ext.global);
request = me.createRequest(options, requestOptions);
return request.start(requestOptions.data);
...
},
...
setOptions: function(options, scope) {
...
// 并没有使用options.data
data = options.rawData || options.binaryData || options.xmlData || jsonData || null;
...
return {
url: url,
method: method,
data: data || params || null
};
}
...