使用javascript,如何从PHP返回的arr中分离JSON对象

时间:2018-09-20 00:22:40

标签: javascript php arrays

PHP将以下内容返回给javascript

[{"uniq":"358","ulot":"S803.45","lname":"Algeri","fname":"Paul","minit":"","nickname":"","vid":"479480","hphone":"352-555-3242","cphone":"","email":"fubar@comcast.net","password":"popskids","fulltime":"1","expiration":"2018-12-31","posted":"2014-01-01 00:00:00"},

{"uniq":"357","ulot":"S803.45","lname":"Algeri","fname":"Patricia","minit":"","nickname":"Pat","vid":"788636","hphone":"352-555-3242","cphone":"","email":"snafu@comcast.net","password":"popskids","fulltime":"1","expiration":"2018-12-31","posted":"2014-01-01 00:00:00"}]

在我看来,它应该是JSON对象数组。

但是,当我尝试使用array.forEach进行迭代时,我得到了响应数组。forEach不是一个函数。

所以,这不是一个数组,或者我做错了事。

感谢您的帮助。

1 个答案:

答案 0 :(得分:2)

[已编辑]

var res = JSON.parse(data);