当前位置:Gxlcms > html代码 > json传值以及ajax接收_html/css_WEB-ITnose

json传值以及ajax接收_html/css_WEB-ITnose

时间:2021-07-01 10:21:17 帮助过:26人阅读

一开始进入公司,做起项目来比较不知所措,现在一个月过去了,越来越得心应手,下面是json向前端传值以及前端ajax接收,给自己记下也分享给大家。

这是两个类型不同的json与ajax的数据交互(集合、类对象)

JsonConfig jsonConfig = new JsonConfig(); //lenient
jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);
JSONArray json = JSONArray.fromObject(listPm, jsonConfig);
outJSONData(json);

Blog b=(Blog) bgdao.findBlog(Integer.parseInt(id));
b.setBbsCenterStr( new String(b.getBbsCenter()));
JSONArray json = JSONArray.fromObject(b);
outJSONData(json);

ajax接收:

dataType:"json",
success: function(data) {
var crmHtmlg = '';
$.each(data,function(i,comment){
crmHtmlg+=''
+''+comment.bbsTitle+''
+''
});
$('#bowenchakan').html(crmHtmlg);

人气教程排行