Created
June 26, 2014 13:20
-
-
Save mogetutu/24cc6af78c19b2d2a1d1 to your computer and use it in GitHub Desktop.
ajax with class changing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Brck</title> | |
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> | |
<script> | |
setInterval(function(){ | |
$.ajax({ url: "http://localhost:9000/sim.php", success: function(data){ | |
//Update your dashboard gauge | |
console.log(data); | |
if(data == 1) { | |
$("#sim").addClass('active'); | |
} else { | |
$("#sim").removeClass('active'); | |
} | |
}}); | |
}, 300); | |
</script> | |
<style type="text/css" media="screen"> | |
.active { | |
color: red; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="sim"> | |
Something | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment