데이터를 컨트롤러로 보내는 ajax 호출이 있습니다. 컨트롤러는 사용자 객체를 포함하는 JSON 객체를 반환합니다. 내 성공 함수에서 대화 상자를 열고 대화 상자에 사용자의 정보를 표시하려고합니다. jquery 대화 상자에서 JSON 데이터를 표시하는 방법
이
$.ajax({
\t \t type: "get",
\t \t url: $(".user-details-link").attr("href"),
\t \t dataType: "json",
\t \t cache: true,
\t \t error: function(jqXHr,textStatus, errorThrown) {
\t \t \t alert("Error opening dialog:\n" + errorThrown);
\t \t },
\t \t success: function(data){ \t \t \t
\t \t \t $("#view-user").removeClass("hidden");
\t \t \t $("#view-user").dialog(dialogOpts);
\t \t \t $("#view-user").dialog("open");
\t \t \t \t \t
\t \t }
\t \t \t \t \t
});//end ajax
@RequestMapping(value="/admin/user/detail", method=RequestMethod.GET)
public @ResponseBody void userDetail(HttpServletRequest request,
HttpServletResponse response, @RequestParam("id") int id)
throws IOException, JSONException, ServletException{
MMUser user = iUserService.getUser(id);
JSONObject jsonObject = new JSONObject();
jsonObject.put("user", user);
response.setContentType("application/json");
response.getWriter().println(jsonObject);
}
나와 함께 곰하시기 바랍니다 그래서 봄 상당히 새로운 오전을 반환하는 코드입니다. 코드가 정상적으로 작동합니다. json 객체를 JavaScript로 다시 반환하고 있습니다. 나는이 부분과 힘들어하고있다. # view-user div에 사용자의 세부 정보를 표시하고 싶습니다. # view-user div가 대화 상자 안에 표시됩니다. 대화 상자도 작동하지만 내부 정보를 표시하는 방법을 모르기 때문에 비어 있습니다. 이 대화 상자에서 내 데이터를 표시하기 위해 서버의 json 객체를 사용하는 방법이 있습니까? 대신 JSON 개체를 다시 보내는 봄
보기 용 템플릿은 무엇입니까? – ricky