JS 部分
$(document).ready(function() {
//点击我赞同
$("img.zantang").click(function(){
var vote_content= $(this).attr("id");
$.ajax({
type: 'POST',
dataType: 'json',
url: 'test.php',
data: 'vote_content='+ vote_content,
success: function(response){
if('1' == response.voteSuccess){
alert("您已成功投了一票");
document.getElementById('todayscore').innerHTML = response.voteSuceessScore;
}else{
alert(response.voteSuceessScore);
}
}
});
})
})
代码部分
<?php
$todayscore = "对不起,您每天的投票数不能超过30票";
$arr = array('voteSuccess' =>0,'voteSuceessScore' =>$todayscore);
exit(json_encode($arr));
?>