<div class="grid--cell fl1 lh-lg">
<div class="grid--cell fl1 lh-lg">
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, <a href="/help/reopen-questions">visit the help center</a>.
</div>
</div>
</div>
<div class="grid--cell mb0 mt8">Closed <span title="2012-10-06 00:36:16Z" class="relativetime">7 years ago</span>.</div>
</div>
</aside>
I have set up a php counter which is inserted into a webpage which is on a altogether different server/website by using a script element and setting parameters on the url. the count files are saved as PARAMETER.txt . how can i retrieve the count number and insert it onto the external webpage? i have tried loading the txt files using jQuery $.ajax $.get etc however they don't work. how can I get the count number either from the php file with the unique paramter or from the txt file?
<?php
$id = $_REQUEST['id'];
$post = $_REQUEST['post'];
if (!is_dir($id)) {
mkdir($id);
}
if (!empty($post)) {
if(!file_exists($id.'/'.$post.'.txt')) {
$fp = fopen($id.'/'.$post.'.txt',"w");
fwrite($fp,"1");
fclose($fp);
} else {
$hit_count = @file_get_contents($id.'/'.$post.'.txt');
echo $hit_count;
$hit_count++;
@file_put_contents($id.'/'.$post.'.txt', $hit_count);
}
} else {
echo "no post id";
}
?>
</div>
I just tried this on a university computer. This 'error' seems to be due to how the server is configured. Your code returns a number as expected on my own apache, but when I do the same thing on the remote host, the response is 200 ok, but there is nothing in the response text. My guess is that your server is not configured to respond to external calls like that.