网上找了一些资料,都没试验成功,比如都用统一编码utf-8,我也照料着做了,依然无效。
还有个ext2.0的解决方法,是这样说的:打开ext-base.js文件,
找到"application/x-www-form-urlencoded",
改成:
"application/x-www-form-urlencoded; charset=UTF-8" 但ext4.0好像不适用。后来,我用了编码转换的方式,解决了参数中文乱码问题,但表单中的中文内容,却不知道如何解决,有经验或有好的办法的高人,希望指点一二,谢谢。
下面是我找api中的一段代码:Ext.create('Ext.form.Panel', {
title: 'Simple Form',
bodyPadding: 5,
width: 350, // The form will submit an AJAX request to this URL when submitted
url: 'save-form.php', // Fields will be arranged vertically, stretched to full width
layout: 'anchor',
defaults: {
anchor: '100%'
}, // The fields
defaultType: 'textfield',
items: [{
fieldLabel: 'First Name',
name: 'first',
allowBlank: false
},{
fieldLabel: 'Last Name',
name: 'last',
allowBlank: false
}], // Reset and Submit buttons
buttons: [{
text: 'Reset',
handler: function() {
this.up('form').getForm().reset();
}
}, {
text: 'Submit',
formBind: true, //only enabled once the form is valid
disabled: true,
handler: function() {
var form = this.up('form').getForm();
if (form.isValid()) {
form.submit({
method: "post",
params: {name: encodeURIComponent("中文")},//这里的name参数中文乱码好解决
success: function(form, action) {
Ext.Msg.alert('Success', action.result.msg);
},
failure: function(form, action) {
Ext.Msg.alert('Failed', action.result.msg);
}
});
}
}
}],
renderTo: Ext.getBody()
});如果带参数的,用编码再转码就能解决,但字段first和last输入中文时,怎么转码呢?一时比较困惑
还有个ext2.0的解决方法,是这样说的:打开ext-base.js文件,
找到"application/x-www-form-urlencoded",
改成:
"application/x-www-form-urlencoded; charset=UTF-8" 但ext4.0好像不适用。后来,我用了编码转换的方式,解决了参数中文乱码问题,但表单中的中文内容,却不知道如何解决,有经验或有好的办法的高人,希望指点一二,谢谢。
下面是我找api中的一段代码:Ext.create('Ext.form.Panel', {
title: 'Simple Form',
bodyPadding: 5,
width: 350, // The form will submit an AJAX request to this URL when submitted
url: 'save-form.php', // Fields will be arranged vertically, stretched to full width
layout: 'anchor',
defaults: {
anchor: '100%'
}, // The fields
defaultType: 'textfield',
items: [{
fieldLabel: 'First Name',
name: 'first',
allowBlank: false
},{
fieldLabel: 'Last Name',
name: 'last',
allowBlank: false
}], // Reset and Submit buttons
buttons: [{
text: 'Reset',
handler: function() {
this.up('form').getForm().reset();
}
}, {
text: 'Submit',
formBind: true, //only enabled once the form is valid
disabled: true,
handler: function() {
var form = this.up('form').getForm();
if (form.isValid()) {
form.submit({
method: "post",
params: {name: encodeURIComponent("中文")},//这里的name参数中文乱码好解决
success: function(form, action) {
Ext.Msg.alert('Success', action.result.msg);
},
failure: function(form, action) {
Ext.Msg.alert('Failed', action.result.msg);
}
});
}
}
}],
renderTo: Ext.getBody()
});如果带参数的,用编码再转码就能解决,但字段first和last输入中文时,怎么转码呢?一时比较困惑
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货