日期:2014-05-16  浏览次数:20366 次

各位大神求解,用jquery,从页面传一个json给action
var m1 = {"username":"wys","password":"dfd"};
function get3(){
$.ajax({
url:'xxx.action',
type:'post',
data:{'m1':m1},
dataType:'json',
success:function(data){
alert(data);
},
error:function(){
alert('错误');
}


});
}
action里面有m1的setget方法。死活传不过去,大神帮帮忙解决一下

------解决方案--------------------
var m1 = '{"username":"wys","password":"dfd"}';
...
data:{"m1":m1}; //action取m1

或者就
var m1 = {"username":"wys","password":"dfd"};
...
data:m1, // action直接取 username