November 2nd, 2014

Lost password?
Advanced Search

— Forum Scope —

— Match —

— Forum Options —

Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
Parse json data into coldfusion code
Forum Posts: 5
Member Since:
sp_UserOfflineSmall Offline


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

<cfajaxproxy cfc="components.acct.accttrx"> <script src="../jQuery/js/jquery-1.7.2.min.js"></script> <cfparam name="prD" default="0_0"> <cfparam name="sM" default="1"> <cfparam name="sY" default="2013"> <cfparam name="status" default="0"> <cfparam name="FORM.fileformat" default="html"> <script type="text/javascript"> jQuery(document).ready(function(){ var myURL = '../components/acct/accttrx.cfc'; function populateReport(){ $.ajax({ url: myURL + "?method=GetTranactions", type: 'POST', data: { prID: '<cfoutput>#prD#</cfoutput>', mn: '<cfoutput>#sM#</cfoutput>', yr: '<cfoutput>#sY#</cfoutput>', st: '<cfoutput>#status#</cfoutput>', ea_adm:'1', slist:'', lang: '1' }, dataType: "json", success: function(data){ $.each(data, function(index, item) { //(item.description,item.balance,item.accttrx_status); // I need help from this point to pass // data to cfml part of my code }); }, error: function(){ alert("An error has occurred while fetching records"); } }); populateReport(); }); </script> </HEAD> <body> <cfif FORM.fileformat Eq 'excel'> <cfset VARIABLES.vcFilename = "thisreport_" & DateFormat(Now(), "yyyymmdd") & "-" & TimeFormat(Now(), "HHmmss") & ".xls"> <cfsetting enablecfoutputonly="Yes"> <cfcontent type="application/"> <cfheader name="Content-Disposition" value="inline;filename=""#VARIABLES.vcFilename#"""> <cfoutput> <!--- here display data from JSON object ---> </cfoutput> <cfsetting enablecfoutputonly="No"> <cfelse> <div id="reportcontents" /> <!--- display row html ---> </cfif>

Below is the Response:

   "description":"ABC Company",
   "ee_name":"Jon, Doe",
   "description":"ABC Company",
   "ee_name":"James, Done",
Forum Timezone: Europe/Sofia

Most Users Ever Online: 496

Currently Online:
31 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam,

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information