views:

73

answers:

1

I have this jquery code right now and it's working fine. What it does it when a user clicks the submit button, it would hide the form, show the loader, then submit the data to a link and load the output in an iframe.

$(document).ready(function() {

$("#xxx_form").validate({
    submitHandler: function() {
        $('#input_form').hide('slow');
        $('#loader').show('slow');
        form.submit();
    }
});

$("#xxx_frame").load(function (){
    $('#loader').hide('slow');
    $('#history').show('slow');
    $('#xxx_frame').show('slow');
});

});

This is working fine. What I need is how to check if the iframe loaded fine or not. During my testing their are times when the iframe would timeout or give an error that it can't connect to the server. Due to ISP failure. Now I need to check for this kind of errors, how can I do this?

+1  A: 

As far as I can see, there is no way to test for an error within an iframe. There is the .error() event but according to a comment in the documentation:

Using .error() on an iframe never seems to trigger (even though .load() will trigger on a successful iframe load).

maybe you need to implement some kind of timeout yourself using the .load() event: If the load event (signifying success) doesn't fire within, say, five seconds, assume an error.

Pekka