今天做ajax获取数据,再浏览器的debugger窗口也看到了数据
ajax代码
$('#userSearch').click(function(){
$.get("loadAllUsers", function(data){
alert("Data Loaded: " + data);
});
});
json数据
{"code":0, "data":"[{"userEmail":"xxx","userId":1,"userName":"zyl","userPassword":"xxx","userStatus":"1","userType":"0"},{"userEmail":"xxx","userId":2,"userName":"zyl","userPassword":"xxx","userStatus":"2","userType":"0"}]"}
后来仔细检查后发现是json格式有问题,data的值是数组不需要“”
如果大家也遇到这个问题,可以看下json是否有问题