Home  >  Article  >  Backend Development  >  php+jquery+ajax开发抽奖功能模块下载

php+jquery+ajax开发抽奖功能模块下载

WBOY
WBOYOriginal
2016-06-20 13:02:00985browse

php+jquery+ajax实现抽奖系统模块代码如下:

首页在抽奖前需要将所有人员的参与名单在屏幕上滚动显示,所以就用jquery实现了,

1. 参与名单将放在一个txt文件里面,我将放到 phones.txt:

首先用ajax读取读取数据:

get_set.php文件直接读取phones.txt文件,将参与名单用“,”连接成字符串,然后利用js的Array split方法分隔成数组. 抽奖时是显示一些随机数字,跳动时间为10ms。

get_set.php:

';
         print_r($phones); */
        //Echo $phones;
    }
                                  
    if(isset($_POST['action']) && $_POST['action'] == 'set'){
                                      
        $rs = $_POST['rs'];
        $data = str_replace(',', "\r\n", $rs);
        $file = './rs.txt';
        file_put_contents($file, $data);
        return true;
    }
?>

中奖的名单将自动写入到 rs.txt文件,而且中奖后将不再参与下一轮抽奖。

开始抽奖(或者 按 Space空格键开始/停止)


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn