- 相關(guān)推薦
PHP+Ajax+lottery.js抽獎(jiǎng)
想用PHP來(lái)做一個(gè)抽獎(jiǎng)的頁(yè)面?下面是由百分網(wǎng)小編為大家整理的PHP+Ajax+lottery.js抽獎(jiǎng)?wù)麄(gè)流程,喜歡的可以收藏一下!了解更多詳情資訊,請(qǐng)關(guān)注應(yīng)屆畢業(yè)生考試網(wǎng)!
其代碼如下:
獎(jiǎng)品列表
<div class="lottery_list clearfix" id="lottery">
<ul>
<li class="lottery-unit lottery-unit-0 lottery-1"><img src="images/1.png"></li>
<li class="lottery-unit lottery-unit-1 lottery-2"><img src="images/2.png"></li>
<li class="lottery-unit lottery-unit-2 lottery-3"><img src="images/3.png"></li>
<li class="lottery-unit lottery-unit-7 lottery-4"><img src="images/4.png"></li>
<li><a href="javascript:void(0);"><img src="images/middle.jpg"></a></li>
<li class="lottery-unit lottery-unit-3 lottery-5"><img src="images/5.png"></li>
<li class="lottery-unit lottery-unit-6 lottery-6"><img src="images/6.png"></li>
<li class="lottery-unit lottery-unit-5 lottery-7"><img src="images/7.png"></li>
<li class="lottery-unit lottery-unit-4 lottery-8"><img src="images/8.png"></li>
</ul>
</div>
Ajax抽獎(jiǎng)
$.post("ajax.php", function(data) { //獲取獎(jiǎng)品,也可以在這里判斷是否登陸狀態(tài)
if (data.prize_id != '' && data.prize_id != undefined) {
var prize_site = $(".lottery-" + data.prize_id).attr("data-ord");
$("#lottery").attr("prize_site", prize_site);
$("#lottery").attr("prize_id", data.prize_id);
$("#lottery").attr("prize_name", data.prize_name);
$("#lottery").attr("prize_pic", data.prize_pic);
if (data.code == 200) {
$("#lottery").attr("contact_name", data.contact_name);
$("#lottery").attr("contact_mobile", data.contact_mobile);
$("#lottery").attr("contact_addr", data.contact_addr);
}
roll();
click = true;
return false;
} else {
showLotteryTip(data.error);
}
}, "json")
保存收獎(jiǎng)地址
$.post("ajax.php", {contact_name: contact_name, contact_mobile: contact_mobile, contact_addr: contact_addr}, function(data) {
$("#lottery_addr_box").modal('hide');
if (data.code == 200) {
$("#tip_words").html("提交成功!");
getModalBox('#lottery_tip');
} else {
showLotteryTip(data.error);
}
}, "json")
【PHP+Ajax+lottery.js抽獎(jiǎng)】相關(guān)文章:
PHP實(shí)現(xiàn)抽獎(jiǎng)概率算法09-13