I am working on an ajax-enabled page, and I need to upload files without refreshing the page. To do this, I added a hidden iframe on the page.
<iframe id="iframeDownload" style="display:none"></iframe>
When I need to upload a file, I use a script as follows:
$("#iframeDownload").attr("src","url to server");
On the server side, I need to implement some logic, and it can return several different http status codes to indicate problems on the server side. If the file is downloaded successfully, then this is normal. But in case of a server-side problem, I need to catch these http codes.
$("#iframeDownload").load(function(e){
Thanks for any answer.
Update: In my opinion, when we load through an iframe, the browser will process send requests and receive responses and only transmit the response body to the iframe. Therefore, javascript cannot read the response header. This case is similar to page loading. Please correct me if I am wrong.
Khanh to
source share