public void topicsByChannel(Integer channelId, HttpServletResponse response)
throws JSONException {
JSONArray arr = new JSONArray();
if (channelId != null) {
List<CmsTopic> list = manager.getListByChannel(channelId);
JSONObject o;
for (CmsTopic t : list) {
o = new JSONObject();
o.put("id", t.getId());
o.put("name", t.getName());
arr.put(o);
}
}
ResponseUtils.renderJson(response, arr.toString());
}
/**
* 发送xml。使用UTF-8编码。
*
* @param response
* HttpServletResponse
* @param text
* 发送的字符串
*/
public static void renderXml(HttpServletResponse response, String text) {
render(response, "text/xml;charset=UTF-8", text);
}
/**
* 发送内容。使用UTF-8编码。
*
* @param response
* @param contentType
* @param text
*/
public static void render(HttpServletResponse response, String contentType,
String text) {
response.setContentType(contentType);
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
try {
response.getWriter().write(text);
} catch (IOException e) {
log.error(e.getMessage(), e);
}
}
jQuery.ajax({
type: "post",
url: "talent_delete.jspx?tid="+id,
dataType: "json",
success: function(data){
if(date="sucess"){
alert("删除成功");
window.location.href="talent_list.jspx";
}else{
alert("删除失败!");
}
}
});