I want to send a file to be downloaded via a "Save as..." type dialog in the client's browser. This requires a special set of HTTP headers. However, I would also like to update the requesting webpage at the same time, AJAX-style. Unfortunately, the two sets of headers must be different, and are not mutually compatible. My attempts so far have simply broken the file download, which is otherwise working.

Can I use a fork { ... } type of command to send back the file while still updating the webpage via AJAX? If so, how is this done? Which response should go back to the browser first, or does fork { ... } end up creating a race condition?

I'm not sure where to start looking for the direction to go with this, so any coding suggestions are welcome. Please note that I am not looking for a package--I have the downloading working already, and have learned to program the AJAX myself. I'm just needing to know how, if this is possible, to do both at the same time.

Blessings,

~Polyglot~


In reply to Can two separate responses be sent to the client's browser from Perl, such as via fork{}? by Polyglot

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.