json传值以及ajax接收详解
一开始进入公司,做起项目来比较不知所措,现在一个月过去了,越来越得心应手,下面是json向前端传值以及前端ajax接收,给自己记下也分享给大家。
这是两个类型不同的json与ajax的数据交互(集合、类对象)
JsonConfigjsonConfig=newJsonConfig();//lenient jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT); JSONArrayjson=JSONArray.fromObject(listPm,jsonConfig); outJSONData(json); Blogb=(Blog)bgdao.findBlog(Integer.parseInt(id)); b.setBbsCenterStr(newString(b.getBbsCenter())); JSONArrayjson=JSONArray.fromObject(b); outJSONData(json);
ajax接收:
dataType:"json", success:function(data){ varcrmHtmlg=''; $.each(data,function(i,comment){ crmHtmlg+='<tr>' +'<tdcolspan="2"style="text-align:center;color:black;font-size:18px;font-weight:bold;">'+comment.bbsTitle+'</td>' +'</tr>' }); $('#bowenchakan').html(crmHtmlg);
以上这篇json传值以及ajax接收详解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。