我有一个从我的CXF Rest服务返回的ArrayList,但是我无法解析它以使用JQuery在客户端显示详细信息。
感谢任何帮助
感谢, 鲍勃
**Sample Code:**
This is how my code looks :
@GET
@Path("/{id}")
@Produces("application/json")
public Response getDetails(@PathParam("id") Long id) {
// data is retreied from database.
List<UserBO> userBOList = new ArrayList<UserBO>();
Response response = Response
.status(Response.Status.OK)
.entity(userBOList)
.build();
return response;
}
===================================================================
My Javascript code:
var url = "http://localhost:8080/user/1";
$("#submit").click(function(){
$.ajax({
type: "GET",
url: url,
beforeSend: function(xhrObj){
xhrObj.setRequestHeader("Origin","null");
},
contentType : "application/json",
dataType : "json",
success: function(data) {
alert( "Data Saved : " + data );
}
});
});
答案 0 :(得分:0)
你可以在JavaScript中循环遍历数组:
for (a in Array){
var item = Array[a];
}