下面的代码是另一个php echo页面的结果
user_list.php:
$myarray=array();
...
...
$myjson = json_encode($myarray);
echo $myuser->searchUser($myjson);
html的结果是:
[{"userID":"1","username":"\\u9ec3\\u9ec3\\u9ec3",
"sex":"F","password":"1bbd886460827015e5d605ed44252251",
"emails":"[email protected]","regdate":"2015-11-03 00:00:00",
"dob":"1994-11-02","educationID":"6","positionID":"1",
"home":"12341234","mobile":"21800000","address":"AC2 5\\/F Rm5501","grade":"Y1","status":"0","office_tel":"41234123",
"inviter":null,"inviter_relation":null,"believe":"0",
"remark":null}]
正如我所知,这里是一个数组而不是一个对象。那么我如何才能在其他页面中获得这些数据呢?
$(".edituser").click(function () {
var user = $(this).data("id");
$.ajax({
url:"user_list.php",
data:"userID="+user,
type : "POST",
dataType: "json",
success:function(data){
console.log(data);
},
error:function(xhr){
alert(\'Ajax request fail\');
}
});
});
如何在ajax中获取数据?thx公司