encodeURI(url)就行了,服务器端可以得到正确的中文
JScript code
Ext.Ajax.request({
url :'./json/role_add.action?role.roleid='
+param.id+'&role.roleName='
+encodeURI(param.name)+'&role.roleDesc='+encodeURI(param.desc),
success: function(response) {
Ext.Msg.alert('成功', response.responseText);
},
failure: function(response) {
Ext.Msg.alert('失败', response.responseText);
}
});
JScript code
Ext.Ajax.request({
url :'./json/role_add.action?role.roleid='
+param.id+'&role.roleName='
+encodeURI(param.name)+'&role.roleDesc='+encodeURI(param.desc),
success: function(response) {
Ext.Msg.alert('成功', response.responseText);
},
failure: function(response) {
Ext.Msg.alert('失败', response.responseText);
}
});
本文介绍如何在服务器端正确处理中文参数,使用encodeURI进行URL编码,并利用Ajax请求发送到指定的JSON服务端点。通过示例展示了如何在JavaScript中构建和发送包含中文参数的Ajax请求。
5898

被折叠的 条评论
为什么被折叠?



