I have a CFC that cycles through a folder and deletes any files in said folder, sort of a 'clean-up' function after an image is uploaded and saved. In that same CFC I have a function that updates text in a database. Bot functions are fired through a jQuery post. The text function returns some a confirmation to my jQuery function, no problem.
But, the clean-up function isn't returning data to my page. Can anyone see an obvious error in my coding that would keep the clean-up function from returning data to my page and firing the confirmation?
I know the CFC is working because the files are deleted from the folder but it's simply not returning a 'valid' response.
Here's the jQuery:
function rebinder(deleteImages){
$('.editingFormField').attr('value', '');
if ($('.edit').hasClass('selected')){
$('.edit').removeClass('selected');
}
$('#imagePreview').attr('src', '');
$('#et').dialog('close');
$('#ei').dialog('close');
if (deleteImages == 'yes'){
$.post("cfc/engine.cfc?method=clearImages&returnformat=json",
{},
function(ret) {
//Handle the result
alert(ret + "the Return");
if(ret == "true") {
} else {
alert("There was an error in the processing (files_no_del)");
}
});
$.post("cfc/engine.cfc?method=clearThumbs&returnformat=json",
{},
function(ret2) {
//Handle the result
if(ret2 == "true") {
} else {
alert("There was an error in the processing (thumbs_no_del)");
}
});
}
location.reload();
};
And the CFC:
<cffunction name="clearImages" access="remote" output="false" returntype="boolean">
<cfset var deleteConfirm = "true">
<!--- Read Holding Directory --->
<cfdirectory
action="list"
directory="#destdir#"
recurse="true"
listinfo="name"
name="qFile"
/>
<!--- Loop through file query and delete files --->
<cfloop query="qFile">
<cffile action="delete" file="#destdir#/#qFile.name#">
</cfloop>
<cfreturn deleteConfirm>
</cffunction>