What I am doing is calling a jQuery function which then uses a CFC method to create my file. I am returning a message of how many files were created and zipped up. I then want to present the user with the File Download box to download the newly created file. It seems the cffunction does not like to have the cfheader/cfcontent in the same function so I put it in its own function. It appears the 2nd function call is returning the file contents to my $get result set. If I call the function directly from a CFM page, the File Download box will appear. Below is my cfc call and my cffunctions...
function exportPartsData(){ // Set a hidden variable to the selected rows lsa_aIds getGridValues(); // Set variables var aplsToUse = $('#selectedGrid').val(); var outputType = $('input:radio[name=fileType]:checked').val(); $.getJSON("services/Parts.cfc?ajaxTS=<cfoutput>#Now()#</cfoutput>&_cf_nodebug=true", {method:'exportData', idsToUse:idsToUse, cache: false }, function(data){ alert("'"+data+"'" + " Records Exported into a zip file into the selected directory."); // Present the user the a File Download Box $.get("services/Parts.cfc?ajaxTS=<cfoutput>#Now()#</cfoutput>&_cf_nodebug=true", {method:'openFile', cache: false }, function(data){ //alert(data); } ); } ); } .... CFFUNCTIONS... <cffunction name="exportData" access="remote" returnformat="json" returntype="any"> <cfargument name="idsToUse"> <cfset test = "this is my test file."/> <cffile action="write" file="c:\test.txt" output="#variables.test#"/> <cfset fileCount = ListLen(idsToUse)/> <!--- Return the Count of files we created ---> <cfreturn fileCount /> </cffunction> .... <cffunction name="openFile" access="remote" returnformat="plain" returntype="Any" hint="Function which will present the download box"> <!--- Present the download box ---> <cfheader name="Content-disposition" VALUE="attachment;filename=test.txt"> <cfcontent type="application/octet-stream" FILE="c:\test.txt"> <cfreturn /> </cffunction> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:337048 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm