We have an HTML/JS animation which is basically a fancy counter. The actual counter part is a div the value for which gets loaded from a PHP script that spits out a random number. It looks like this:
<?php
$val = file_get_contents("num.txt");
$val += rand(1, 5);
file_put_contents("num.txt", $val);
print $val;
We are hosting this PHP file on an external domain, because this animation will be packaged as part of an iPad publication. The idea is that when our animation gets loaded it will call to our PHP file and get it's value from there.
I was wondering what the most straightforward way of loading this data would be.
The div for the text part of the counter that we are changing is #Stage_Text. I've tried the following approach in the html of the animation, which unfortunately did not work:
$(document).ready(function () {
$.ajax({
url : "http://ourdomain.com/stat.php",
dataType: "text",
success : function (result) {
$("#Stage_Text").html(result);
}
});
});
Any assistance would be greatly appreciated.