Skip to content

Instantly share code, notes, and snippets.

@mogetutu
Created June 26, 2014 13:20
Show Gist options
  • Save mogetutu/24cc6af78c19b2d2a1d1 to your computer and use it in GitHub Desktop.
Save mogetutu/24cc6af78c19b2d2a1d1 to your computer and use it in GitHub Desktop.
ajax with class changing
<!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