3

Here is the downloadURL function which I'm using to download a file:

function downloadURL(url) {
    var hiddenIFrameID = 'hiddenDownloader',
    iframe = document.getElementById(hiddenIFrameID);
    if (iframe === null) {
    iframe = document.createElement('iframe');
    iframe.id = hiddenIFrameID;
    iframe.style.display = 'none';
    document.body.appendChild(iframe);
    }
    iframe.src = url;
};

This can work perfectly for downloading a file, but right now, I want to get the return http status code, if the http status code is not 200, I'd like to alert something out.

Could anyone tell me how to retrieve that? Thanks in advance.

Judking
  • 6,111
  • 11
  • 55
  • 84
  • 2
    I don't think you can get the status code from an iframe. You can try adding an `onload` event to the iframe. The event object might have some useful info. – gen_Eric Nov 01 '13 at 17:18
  • Could you give me some specific thing like code snippet? I'm new to javascript and I hope you can prove what you say :) Thanks bro~@RocketHazmat – Judking Nov 01 '13 at 17:27
  • http://stackoverflow.com/questions/2955947/how-do-i-get-the-http-status-code-with-jquery – el Dude Nov 01 '13 at 19:34

1 Answers1

0

It seems that it is not possible. You can try with ajax as it is shown here: Use javascript to check http status codes

Community
  • 1
  • 1
Sulot
  • 504
  • 2
  • 6
  • 20