Home  >  Article  >  Web Front-end  >  json传值以及ajax接收_html/css_WEB-ITnose

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

WBOY
WBOYOriginal
2016-06-24 11:17:14959browse

一开始进入公司,做起项目来比较不知所措,现在一个月过去了,越来越得心应手,下面是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);
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn