我有一张图片:
<img src="imagini/floo.gif" onclick="score()">我想“点击”被打开一个文件"c.txt“。该文件的内容为:0
我希望每点击一次,在c.txt中就会增加100个。
我想要这样的东西:
<img src="imagini/floo.gif" onclick="score()">
<script> function score(){ (..do file add.php ...) }</script>和add.php:
<?php
$c = "c.txt";
$fh = fopen($c, "r");
$current = fread($fh, filesize($c));
fclose($fh);
$current++;
$fh = fopen($c, "w");
fwrite($fh,$current);
fclose($fh);
?>放置内容:"(..do文件add.php ...)“为了让代码正常工作?
发布于 2013-03-17 02:28:27
您需要发送一个AJAX请求来处理该文件。以下是代码的jQuery版本:
function score() {
$.post("add.php", function(data) {
//This callback executes after the request was successfull
// echo something back to read from here as `data`
console.log(data);
});
}https://stackoverflow.com/questions/15452971
复制相似问题