I am currently finishing off a module which creates a new node type with attached images and which offers the user a download option that produces a RTF/DOC of the page complete with its images embedded.

I've integrated in http://www.phprtf.com/ into my module to generate the document. The download option on the page is a Drupal based menu link which does a page callback and uses the "phprtf" API to build up the RTF. Once the RTF is generated, the content is provided as a file download that is sent via the headers. So when the user clicks the link, after a short wait a download prompt will appear and keep the user on the same page they clicked the download link on.

However, for nodes with many images on, the RTF generation can take up to 10 seconds to produce and as a result it would be useful to include a "Please wait" dialog/throbber to let the user know that something is happening.

JQuery Ajax I think seems to be the route to go down and attaching an onclick action to the link. I have messed around with the $.ajax command in JQuery ... but wasn't sure how to get and return the RTF content generated to the header and get the download prompt like I am with PHP. From what I understand, with the $.ajax function I might be able to use the subsequent functions: .ajaxstart and .ajaxstop to get the "Please wait" dialog appearing and disappearing.

Any help/suggestions would be really great - this is my first time messing around with Ajax. If i'm also going down the wrong route, then please let me know :)

Many thanks!