Trouble Shoot JavaScript Function in IE
Posted
by CreativeNotice
on Stack Overflow
See other posts from Stack Overflow
or by CreativeNotice
Published on 2010-03-23T19:31:56Z
Indexed on
2010/03/23
19:33 UTC
Read the original article
Hit count: 377
So this function works fine in geko and webkit browsers, but not IE7. I've busted my brain trying to spot the issue. Anything stick out for you?
Basic premise is you pass in a data object (in this case a response from jQuery's $.getJSON) we check for a response code, set the notification's class, append a layer and show it to the user. Then reverse the process after a time limit.
function userNotice(data){
// change class based on error code returned
var myClass = '';
if(data.code == 200){ myClass='success'; }
else if(data.code == 400){ myClass='error'; }
else{ myClass='notice'; }
// create message html, add to DOM, FadeIn
var myNotice = '<div id="notice" class="ajaxMsg '+myClass+'">'+data.msg+'</div>';
$("body").append(myNotice);
$("#notice").fadeIn('fast');
// fadeout and remove from DOM after delay
var t = setTimeout(function(){ $("#notice").fadeOut('slow',function(){ $(this).remove(); }); },5000);
}
© Stack Overflow or respective owner