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.

2
  • 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. Commented Sep 9, 2013 at 10:35
  • I can't make an ajax call, IE8 doesn't support FormData Commented Sep 9, 2013 at 20:04

1 Answer 1

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{

    }
});
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.