Trouble Shoot JavaScript Function in IE
- by CreativeNotice
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);
}