춘향이에게....
본문
좀 핵갈려서 그러는데요,,
내가 춘향이 한테 쪽지를 보내면
아래코드가 쪽지있는지 알려주는거죠?
$act = $_POST['act'];
if ($act =='alim') {
$result = array();
$row = sql_fetch(" select * from {$g5['memo_table']} where me_recv_mb_id = '{$member['mb_id']}' and me_send_datetime >= NOW() - INTERVAL 2 DAY and me_read_datetime = '0000-00-00 00:00:00' order by me_id desc limit 1");
if ($row) {
$result['content'] = $row['me_memo'];
$result['msg'] = 'SUCCESS';
$result['me_id'] = $row['me_id'];
//$result['sound'] = 'N';
$mb = get_member($row['me_send_mb_id'], 'mb_name');
$result['title'] = $mb['mb_name'];
$result['me_subject'] = $row['me_subject'];
$result['me_link'] = $row['me_link'];
$result['direct_link'] = $row['direct_link'];
$result['url'] = G5_URL . '/bbs/memo_view.php?me_id=' . $row['me_id'] . '&kind=recv';
}else{
$result['msg'] = 'NOMSG';
$result['me_id'] = '';
}
echo json_encode($result);
}
if($act == "recv_memo"){
$result = array();
$me_id = $_POST['me_id'];
$sql = " update {$g5['memo_table']}
set me_read_datetime = '".G5_TIME_YMDHIS."'
where me_id = '$me_id'
and me_read_datetime = '0000-00-00 00:00:00' ";
sql_query($sql);
$result['msg'] = 'SUCCESS';
echo json_encode($result);
}
그리고 아래 코드가 새로고침 없이도 ajax로
var show_alim_exist=false;
function check_alim(){
$.ajax({
type:'POST',
data : ({act : 'alim'}),
url: memo_alim_url + '/get-alim-events.php',
dataType:'json',
async:true,
cache:false,
success:function(result){
if(result.msg=='SUCCESS'){
show_alim(result.title, result.me_subject, result.content, result.me_link, result.direct_link, result.url, result.me_id);
}else{
}
}
});
}
function show_alim(title, me_subject, content, me_link, direct_link, url, me_id){
if(show_alim_exist) hide_alim();
show_alim_exist=true;
var html = "";
audio.play();
html = "<div id='alim_layer' class='wrapper-alert-circle' style='display:none'>";
html += "<div class='notification notification-primary notification-msg animated bounceInUp' id='" + me_id + "'>";
html += "<div class='right-check-button'></div>";
html += "<div class='notification-close'>";
html += "<button class='close' onclick='hide_alim()'><i class='fa fa-times fa-lg'></i></button>";
html += "</div>";
html += "<div class='notification-option'><span class='fa-fa-check' data-toggle='tooltip' data-trigger='hover' data-html='true' data-placement='top' data-original-title='읽음' onclick='set_recv_memo(" + me_id + ")'><i class='fa fa-check'></i></span></div>";
html += "<div class='notification-subject'><a onclick=\"href='" + direct_link + "'; $('.fa-fa-check').trigger('click');\" class=\"cursor\">" + me_subject + "</a></div>";
html += "</div>";
html += "</div>";
$('#notificate').append(html);
$('#alim_layer').fadeIn();
setTimeout(function(){ hide_alim(); }, 30000);
}
갱신해주는거죠?
혹시 맞나요?