JSON pass value and Ajax receive detailed _javascript tips

Source: Internet
Author: User

The beginning of the company, to do the project to be more overwhelmed, now one months later, more and more handy, the following is JSON to the front-end value and front-end Ajax to receive, to write down also share to everyone.

This is two different types of JSON interacting with Ajax data (collections, class objects)

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 Receive:

DataType: "JSON",
success:function (data) {
var crmhtmlg = ';
$.each (Data,function (i,comment) {
crmhtmlg+= ' <tr> '
+ ' <td colspan= ' 2 "style=" text-align:center; Color:black;font-size:18px;font-weight:bold; " > ' +comment.bbstitle+ ' </td> '
+ ' </tr> '
});
$ (' #bowenchakan '). HTML (CRMHTMLG);

Above this JSON pass value and the Ajax receive the detailed explanation is small arranges to share to everybody's content, hoped can give everybody a reference, also hoped that everybody supports the cloud habitat community.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.