Backstage to the foreground of the JSON string, the foreground parsing and stitching display

Source: Internet
Author: User

Background JSON

1  Public classCoursetype:ihttphandler2     {3Epoint.PeiXun.Bizlogic.BLL.CourseLibrary.PX_CourseType.B_PX_CourseType B_coursetype =NewEpoint.PeiXun.Bizlogic.BLL.CourseLibrary.PX_CourseType.B_PX_CourseType ();4 5List<coursetypedata> List_coursetype =NewList<coursetypedata>();6Coursetypechartdata COURSETYPECD =NewCoursetypechartdata ();7          Public voidProcessRequest (HttpContext context)8         {9             stringRjson =string. Empty;Ten  One             Try A             { -                 intCount1; -                 string where="where 1=1"; theDataView DV =Epoint.MisBizLogic2.DB.GetData_Page_ByConnName ( -                    "*", -                     -, -                    1, +                    "Px_coursetype",//Frame_attachinfo and Nti_coursechapter -                    "row_id", +                    where, A                    "Parentrowid asc,ordernum desc", at                     outCount1, -                    "djg_peixun_connectionstring" -                    ). DefaultView; -Coursetypecd.picnum =convert.tostring (DV. Count); -                  for(inti =0; I < DV. Count; i++) -                 { inList_coursetype.add (NewCoursetypedata (Convert.ToString (dv[i]["TypeName"]. ToString ()), Convert.ToString (dv[i]["Parentrowid"]. ToString ()), Convert.ToString (dv[i]["row_id"]. ToString () )); -                 } toCoursetypecd.coursedata =List_coursetype; +Rjson =NewEpoint.KSPXBase.Bizlogic.DB_Common (). Obj2json (COURSETYPECD); -  the             } *             Catch $             {Panax NotoginsengRjson ="0"; -             } the  +Context. Response.ContentType ="Text/plain"; AContext. Response.Write (Rjson);//returns the call point the         } +  -          Public BOOLisreusable $         { $             Get -             { -                 return false; the             } -         }Wuyi  the         Internal classCoursetypedata -         { Wu              PublicCoursetypedata (stringTypeName,stringParentrowid,stringrow_id) -             { AboutTypeName = TypeName;//Category name $Parentrowid =Parentrowid; -ROW_ID =row_id; -             } -              Public stringTypeName; A              Public stringParentrowid; +              Public stringrow_id; the         } -  $  the         Internal classCoursetypechartdata the         { the              Public stringPicnum;//Number of data the              PublicList<coursetypedata>Coursedata; -         } in}
View Code

Front desk parsing, and stitching display

1$ (function () {//Load Course Recommendations2Loadcoursetypename ($ ("#CourseType"));//Load Course3     });4 5 function Loadcoursetypename (obj) {6 $.ajax ({7Type"POST",8ContentType:"Application/json;charset=utf-8",9Url:"<%=request.applicationpath%>/ashx/coursetype.ashx?",TenDataType:'text', One complete:function () {}, A beforesend:function () { -Obj.html ("<div class= ' divloadtips ' > Course content loading in ...</div>"); -             }, the success:function (Result) { -                 varres = Json.parse (result);//Get JSON value -                 varRTN =parseint (Res. Picnum); -Obj.html ("") +                 varspan, A; -                  for(vari =0; i < RTN; i++) { +                     varParentrowid =Res. Coursedata[i]. Parentrowid; A                     if(Parentrowid = ="0") { at                         varROW_ID =Res. Coursedata[i]. row_id; -                         varLi = $ ("<li class= ' drop-menu-item ' id= '"+ row_id +"' > </li>"); -span = $ ("<span class= ' drop-menu-cate ' >"+ Res. Coursedata[i]. TypeName +"</span>") - li.append (span); -                     } -                     Else { in$("#menucourse ul Li"). each ( - function (index) { to  +                                 if($( This). attr ("ID") ==Parentrowid) { -A = $ ("<a href= ' # ' >"+ Res. Coursedata[i]. TypeName +"</a>"); the$( This). append (a); *                                 } $                             }Panax Notoginseng                             ); -   the                     } +  A Obj.append (LI); the                 } +             }, - error:function (result, status) { $ alert (result.responseJSON.Message); $             } -         }) -}
View Code

Backstage to the foreground of the JSON string, the foreground parsing and stitching display

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.