0

The issue is quite simple, I've got a form which targets an iframe. When the form is submitted the load event fires off, so I can use it as a ajax fallback for upload picture functionality for IE8/IE9.

$('#iframe').load(function () {
    // do something
});

This works ok, however the load event fires off even if I get 415 http code back and no response.

How can I retrieve the HTTP status code from the loaded iframe? A solution that doesn't need any server-side adjustments would be really helpful.

Emil A.
  • 3,387
  • 4
  • 29
  • 46
  • 1
    I don't think it's possible as the request was made by the browser itself, therefore javascript cannot get a handle on it to check the response status. If you load the content yourself via `ajax()` you could then check the response. – Rory McCrossan Sep 09 '13 at 10:35
  • I can't make an ajax call, IE8 doesn't support FormData – Emil A. Sep 09 '13 at 20:04

1 Answers1

1

you can't tell success or failure by HTTP Status Code unless you use ajax method, however, you can do this:

$('#iframe').load(function (e) {
    var $iframe = $("#iframe");

    //there is response
    if($iframe.innerHTML){

    }
    //error happens
    else{

    }
});
jasonslyvia
  • 2,529
  • 1
  • 24
  • 33