loginAndRegDialog=$('#loginAndRegDialog').dialog({
closable:false,
modal:true,
buttons:[{
text:"登录",
handler:function(){
var params=$('#LoginInputForm').serialize();
params = decodeURIComponent(params,true);
console.info(params);
$.ajax({
url:'userController.do?login',
data:$('#LoginInputForm').serialize(),
cache:false,
dataType:'json',
success:function(r){
$.messager.alert('My Title',r.msg,'error');
}
});
closable:false,
modal:true,
buttons:[{
text:"登录",
handler:function(){
var params=$('#LoginInputForm').serialize();
params = decodeURIComponent(params,true);
console.info(params);
$.ajax({
url:'userController.do?login',
data:$('#LoginInputForm').serialize(),
cache:false,
dataType:'json',
success:function(r){
$.messager.alert('My Title',r.msg,'error');
}
});
}
就是在调用序列化的时候,中文乱码,
原因:.serialize()自动调用了encodeURIComponent方法将数据编码了
解决方法:调用decodeURIComponent(XXX,true);将数据解码
例如:
var params=$('#LoginInputForm').serialize();
params = decodeURIComponent(params,true);
还有一种办法是直接 --- console.info($('#name').val());
loginAndRegDialog=$('#loginAndRegDialog').dialog({
closable:false,
modal:true,
buttons:[{
text:"登录",
handler:function(){
var params=$('#LoginInputForm').serialize();
params = decodeURIComponent(params,true);
console.info($('#name').val());
$.ajax({
url:'userController.do?login',
data:$('#LoginInputForm').serialize(),
cache:false,
dataType:'json',
success:function(r){
$.messager.alert('My Title',r.msg,'error');
}
});
closable:false,
modal:true,
buttons:[{
text:"登录",
handler:function(){
var params=$('#LoginInputForm').serialize();
params = decodeURIComponent(params,true);
console.info($('#name').val());
$.ajax({
url:'userController.do?login',
data:$('#LoginInputForm').serialize(),
cache:false,
dataType:'json',
success:function(r){
$.messager.alert('My Title',r.msg,'error');
}
});
}