0

I have what may be a conceptual issue to contend with. I'm not even sure what tags to put it under...

I have an ASP.NET web form application. It has <form method="post"> and uses traditional submit from pages, and server replies with response of new page. It does not use AJAX, callbacks or other asynchronous techniques. It uses JavaScript, but not jQuery.

I have been asked to put up a "modeless window" with "processing, please wait" type message when the user starts a submit for a "long operation".

I have written that part of the code, having JavaScript place a DIV with high z-order on the page when the submit starts. The principle is that when the new page is returned in the response, it replaces the current page and the modeless window goes away too, of course.

All seemed well, till I looked at what happened when, for example, the user action caused the application to send back a file. The web browser asks the user what to do with it, and meanwhile my message is still there. More importantly, the application does not send any new page at all (it just does a Response.End()), so the user is left on the original page with the message still there forever. Another path of code might send back a "response status code 204 no content".

The above is only an example of what a button on the page might ask the server to do. The bottom line is that if the server is not going to send a new page back, I (think I) need to know in the original page's JavaScript when the server has started/completed whatever response it is going to produce so that it can remove the "modeless window".

Is anything possible, given that the page is being submitted from the client?

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
JonBrave
  • 4,045
  • 3
  • 38
  • 115
  • Yes, that's the way to do this. – Pointy Nov 05 '15 at 15:20
  • I do not see that the "duplicate" is an answer to my full question. It is _very_ useful for the download-a-file case, thank you very much. But I said that was only an _example_ of what it might be waiting for. I also said that a page may simply return a Response Status Code of 204, indicating it has no more to say. How could I detect that?? There may be other cases.... – JonBrave Nov 05 '15 at 15:39
  • Well just about any response from the server can include cookies. As far as I know, the cookie solution is the only thing that JavaScript has access to. – Pointy Nov 05 '15 at 15:45
  • If I understand correctly, the principle there is that the server sends a cookie back (presumably in the response header) and that is what the client waits for. If the server sends a status code of 204 and no content, I guess you're saying the client still gets the header and cookies (I kind of thought it sent "nothing")? And, just to be clear, the client does _not_ execute any kind of "load" event (as an alternative)? Thank you so much for answering. – JonBrave Nov 05 '15 at 15:59
  • I don't know for sure that a 204 response can set cookies, but a response header is a response header. If you've done an ordinary form post, then there is no other notification (that I've ever found or heard of) when the response is received and it's not content for a new page load. – Pointy Nov 05 '15 at 16:03

0 Answers0