[英]How do I know if an message has been sent successfully when using raw WebSocket?
[英]How to know when a message has been dismissed with php
我正在向我的應用程序中添加公告,這基本上是給用戶的個人信息。 他們收到消息然后如果他們駁回它我想停止再次顯示該特定內容。
這是我的 php
<? $the_ID = $res_announcement->formal_announcement_id; ?>
<form action method="POST">
<div class="fade in pi-alert-warning pi-no-margin-bottom hide_msg_announcement">
<div class="pi-section pi-row-sm hide_msg_announcement">
<p class="pi-weight-600 pi-no-margin-bottom hide_msg_announcement">
<i class="fa fa-exclamation-triangle pi-text-orange yellow blink_me" aria-hidden="true"></i>
<span class="pi-text-dark"><?= $content_body ?></span>
<?= $url_setup_pm ?>.
</p>
<div class=" pull-right checkbox checkbox-inline" style="margin-top: -16px;">
<input type="checkbox" class="hide_msg_announcement" name="hide_msg" id="hide_msg_announcement" value="yes">
<label class="pi-smaller-text pi-text-grey" for="hide_msg_announcement">dismiss</label>
</div>
</div>
</div>
</form>
然后我用 Jquery 隱藏它,但我不知道如何存儲這個特定的消息 ID 或如何從任何地方獲取它。 我嘗試傳遞 php 變量,但總是為空。 我需要一種存儲消息 ID 的方法,以便我知道不會再次向用戶顯示該消息
jQuery('body').on('change', '.hide_msg_announcement', function(e) {
jQuery(".hide_msg_announcement").hide();
if($(this).is(":checked")) {
$.ajax({
url: 'on_off.php',
dataType:'json',
async:true,
type: 'POST',
data: { strID:$(this)},
error: function(jqXHR, textStatus, errorThrown){
}
});
}
});
將$the_ID
放在 HTML 中,以便 jQuery 可以訪問它。 您可以為此使用data-
屬性。
<input type="checkbox" class="hide_msg_announcement" name="hide_msg" id="hide_msg_announcement" data-msg="<?php echo $the_ID; ?>" value="yes">
然后jQUEry可以使用:
data: {strID: $(this).data("msg");},
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.