请帮助。如何遍历ajax响应并在html表中显示所有用户?
name last state
-------|--------|----|
John Johnson MN
Ashley Moore CA
Bob Hammer NY
这是我的ajax响应:
[
{ 'name': 'John', 'last': 'Johnson', 'state': 'MN' },
{ 'name': 'Ashley', 'last': 'Moore', 'state': 'CA' },
{ 'name': 'Bob', 'last': 'Hammer', 'state': 'NY' }
]
我正在使用GET调用来获取响应并将其显示在表格中:
$.ajax({
url: "/directory/allusers",
type: "GET",
success: function(data) {
},
error: function() {
alert('error: cannot pull profiles');
}
});
谢谢!