Hi
I am working on generating a report with data in JSON format. Here is the action file that receives parameters and displays either html table with data or excel. I need help with parsing JSON data I am getting into required format (html or excel). I know how to work with excel formatting, I just need help with parsing JSON data and outputing it. I someone help me to complete the code, the part where it is passed from jquery to coldfusion. Any help is greatly appreciated.
Thank you
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
<div class="sfcode"><cfajaxproxy cfc="components.acct.accttrx"><br /> <script src="../jQuery/js/jquery-1.7.2.min.js"></script><br /> <br /> <cfparam name="prD" default="0_0"><br /> </cfparam><cfparam name="sM" default="1"><br /> </cfparam><cfparam name="sY" default="2013"><br /> </cfparam><cfparam name="status" default="0"><br /> </cfparam><cfparam name="FORM.fileformat" default="html"><br /> <br /> <script type="text/javascript"><br /> jQuery(document).ready(function(){<br /> var myURL = '../components/acct/accttrx.cfc';<br /> <br /> function populateReport(){<br /> $.ajax({<br /> url: myURL + "?method=GetTranactions",<br /> type: 'POST',<br /> data: {<br /> prID: '<cfoutput>#prD#</cfoutput>',<br /> mn: '<cfoutput>#sM#</cfoutput>',<br /> yr: '<cfoutput>#sY#</cfoutput>',<br /> st: '<cfoutput>#status#</cfoutput>',<br /> ea_adm:'1',<br /> slist:'',<br /> lang: '1'<br /> },<br /> dataType: "json",<br /> success:<br /> function(data){<br /> $.each(data, function(index, item) {<br /> //(item.description,item.balance,item.accttrx_status);<br /> // I need help from this point to pass<br /> // data to cfml part of my code<br /> });<br /> },<br /> error:<br /> function(){<br /> alert("An error has occurred while fetching records");<br /> }<br /> });<br /> populateReport();<br /> });<br /> </script><br /> <br /> <body><br /> <cfif FORM.fileformat Eq 'excel'><br /> <cfset VARIABLES.vcFilename = "thisreport_" & DateFormat(Now(), "yyyymmdd") & "-" & TimeFormat(Now(), "HHmmss") & ".xls"><br /> <cfsetting enablecfoutputonly="Yes"><br /> <cfcontent type="application/vnd.ms-excel"><br /> <cfheader name="Content-Disposition" value="inline;filename=""#VARIABLES.vcFilename#"""><br /> <br /> <cfoutput><br /> <!--- here display data from JSON object ---><br /> </cfoutput><br /> <cfsetting enablecfoutputonly="No"><br /> <cfelse><br /> <div id="reportcontents"></div> <!--- display row html ---><br /> </cfelse></cfsetting></cfheader></cfcontent></cfsetting></cfset></cfif><br /><br /><br /></body></cfparam></cfajaxproxy></div><br />Below is the Response:<br /><br /> |
|
1 |
{"ROWS":[<br /> |
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top