Can anybody tell me why this works?

  • Thread starter The Natural Philosopher
  • Start date
T

The Natural Philosopher

Its not really javascript, or php, or HTML..so excuse posting it here.

I have a form.

On submission it submits to itself, so the normal behaviour is to pass
the data back to the server, do something server side, and redraw itself
with the exact data it had before it was submitted.

Nothing new there.

However one option was to instead of drawing itself, send a downloadable
object: To this end, serverside, instead of sending an updated HTML
version of itself, it sends some headers, and some data as a file
download. And that is ALL it sends.

Now I would have thought that this would in some way cancel the existing
window with the form in it, but it seems that all the browsers I have
tested against take this response - a file rather than an HTML document,
being sent, as a directive to spawn a separate download dialogue box,
and eve the main screen unaltered.

This is in fact exactly what I wanted, and saves me the trouble of
working out how to split the session into two browser windows - getting
the main window back and having a download happen, but can I rely on this?

Is it guaranteed behaviour to some standard, or just 'the way
firefox/safari/IE7 work'?

Apologies for asking here, but I don't even now where to LOOK for the
answer.
 
H

Henry

Its not really javascript, or php, or HTML..so excuse posting
it here.
... , but it seems that all the browsers I have
tested against take this response - a file rather than
an HTML document, being sent, as a directive to spawn a
separate download dialogue box, and eve the main screen
unaltered.
Is it guaranteed behaviour to some standard, or just 'the
way firefox/safari/IE7 work'?

Apologies for asking here, but I don't even now where to
LOOK for the answer.

If there is a positive assertion about how a user agent should handle
a response with a MIME type that it cannot directly display it will be
in RFC 2616 - Hypertext transfer Protocol - HTTP/1.1.
 
D

David Mark

Its not really javascript, or php, or HTML..so excuse posting it here.

What else is new? But since this is a question, no excuse is needed
(assuming it is a good question.)
I have a form.
Okay.


On submission it submits to itself, so the normal behaviour is to pass
Ugh.

the data back to the server, do something server side, and redraw itself
with the exact data it had before it was submitted.
Again.


Nothing new there.

No.

However one option was to instead of drawing itself, send a downloadable
object: To this end, serverside, instead of sending an updated HTML
version of itself, it sends some headers, and some data as a file
download. And that is ALL it sends.

Yes. That sounds familiar.
Now I would have thought that this would in some way cancel the existing
window with the form in it, but it seems that all the browsers I have
tested against take this response - a file rather than an HTML document,
being sent, as a directive to spawn a separate download dialogue box,
and eve the main screen unaltered.

It might surprise you that you can do that with an HTML document as
well.
This is in fact exactly what I wanted, and saves me the trouble of
working out how to split the session into two browser windows - getting
the main window back and having a download happen, but can I rely on this?

Is it guaranteed behaviour to some standard, or just 'the way
firefox/safari/IE7 work'?

There is a standard header for this (Content-Disposition.)
Apologies for asking here, but I don't even now where to LOOK for the
answer.

How about the specifications for the HTTP protocol? And please post
future queries about this (or anything for that matter) elsewhere.
Thank you for your cooperation.
 
T

The Natural Philosopher

Henry said:
If there is a positive assertion about how a user agent should handle
a response with a MIME type that it cannot directly display it will be
in RFC 2616 - Hypertext transfer Protocol - HTTP/1.1.
Ah. Thanks for that at least.
 
T

The Natural Philosopher

The said:
Ah. Thanks for that at least.

Sadly no info I could easily find was relevant.

Does anyone know of an HTTP client that will when given a URL, just show
me what headers are being sent? even if its a file download/image
download target?
 
D

David Mark

Sadly no info I could easily find was relevant.

Does anyone know of an HTTP client that will when given a URL, just show
me what headers are being sent? even if its a file download/image
download target?

I gave you the name of the header and told you this topic was OT here.
 
J

Jorge

Sadly no info I could easily find was relevant.

Does anyone know of an HTTP client that will when given a URL, just show
me what headers are being sent? even if its a file download/image
download target?

Yes: the "net" pane of firebug: in order to monitor any/every network
transaction, click on "net" (a popup will appear) and select "enable
monitor for (domain)".

Or the "resources" pane of the "web inspector" of a *nightly build* of
Webkit: (http://nightly.webkit.org/).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top