Skip to content

Instantly share code, notes, and snippets.

@farindra
Last active August 29, 2015 14:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save farindra/8f00e5f5ec1e879e2147 to your computer and use it in GitHub Desktop.
Save farindra/8f00e5f5ec1e879e2147 to your computer and use it in GitHub Desktop.
auto reload div by jquery from php
<html>
<head>
<title>auto reload div by jquery from php</title>
</head>
<body>
<center><strong><u>This is Realtime data : </u></strong></br>
<div id=content_div_id></div>
</center>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
$(document).ready(function() {
$(function() {
startRefresh();
});
function startRefresh() {
setTimeout(startRefresh,3000);
$.get('value.php', function(data) {
$('#content_div_id').html(data);
});
}
});
</script>
</body>
</html>
</html>
<?php
// Get random number
echo "Random number: " . (string)(rand(0, 50));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment