tags:

views:

127

answers:

4

I need to trigger a page to start acting, without interfering with client's processes.

I am doing a huge csv file upload, and after upload, redirect to an ajax status page....

But how do i trigger a page to be executed without showing that page to the end user...which i don't want to have them see...

Can i use cfschedule to schedule an task to happen immediately, without affecting performance of the client/end user?

Thank You.

A: 

I usually do this by posting the form to an iFrame, and then using javascript, report back to the parent page when the iFrame is done processing. You can access the entire DOM (including calling functions) of the parent page directly from the iFrame.

Also, if you're doing an upload, there's no way to do that with standard AJAX. Posting to an iframe is the way to go... Just specify the target attribute of your FORM tag to match the name attribute of your iframe.

Daniel Short
what about cfthread, is what i need possible there?
crosenblum
A: 

If you are trying to run some sort of task on the file uploaded by the user that the user does not care about you could use an asynchronous gateway call with the SendGatewayMessage function. This will not help you while uploading the file though. As was pointed out uploading via AJAX is at best a hack and much better done through a flash or java solution.

The ColdFusion CFML event gateway lets CFML code send a message to CFC methods asynchronously. This event gateway lets you initiate processing by a CFC method without waiting for it to complete or return a value.

Nick
+1  A: 

We have a system that creates PDFs based on user input. We throw a new thread via CFTHREAD to create the PDF while redirecting to a dashboard page. Simply use CFTHREAD to create a new thread, and do not re-join it to the parent page.

You will need some way to notify the AJAX page (etc.) that the process is finished. Since I don't know what you are doing, I can't be of much help with that part. However, we flagged completed PDFs in the DB.

Ben Doom
right, we did something similar....using a progress bar.
crosenblum
Was going to suggest CFTHREAD as well. It seems perfectly suited for this.
Al Everett
A: 

I did find a way to do this....cfthread, was reading many of ben nadel's articles on cfthread, did it like this...

cfthread action="run" name="moving_#unique_session_value#" cfhttp url="some_url"/cfhttp /cfthread

this is so sweet, allowed me to save performance of the client/end user...

Btw thank you all...

crosenblum