Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Html to have count dumped into - Resides in the DOM.
- <p><span id="count"></span> is the current count number.</p>
- //Javascript call to retrieve count from external text source. Call writeCount(); on Dom load to execute.
- function writeCount(){
- $.get( "count.txt", function(data) {
- $("#count").html( data );
- });
- }
- //count.txt only contains the incremented number.
- // javascript function to increment the count. calls external PHP file. run pushScript(); whenever you want to increment the count (on load, on form submit, whenever);
- function pushScript() {
- $.ajax({ url: 'script.php' });
- }
- //PHP file called that increments the count.
- <?php
- $current = file_get_contents("count.txt");
- $new = $current + 1;
- file_put_contents("count.txt", $new);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement