这里是通知方法
public function activetask() {
$notification['ReceiverID']=$this->input->post('user_reciver_id');
$notification['SenderID']=$this->input->post('createdby');
$notification['Status']=$this->input->post('task');
$notification['AppID']=$this->input->post('App_id');
$notification['TaskID']=$this->input->post('PhaseID');
$notification['CreatedDate']=date('D M Y h:i');
$this->Mapps->notification($notification);
if($this->input->post('user_reciver_id')==$this->session->userdata('id')){
echo '<audio controls autoplay>
<source src="<?php echo base_url(); ?>notify.ogg" type="audio/ogg">
<source src="<?php echo base_url(); ?>notify.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>';
}
此处点击事件的ajax函数调用
function active(task,user_reciver_id,createdby,Task_id,App_id,PhaseID){
$.ajax({
type: "post",
url: '<?php echo base_url();?>users/activetask',
cache: false,
data: {task: task,Task_id:Task_id,App_id:App_id,PhaseID:PhaseID,user_reciver_id:user_reciver_id,createdby:createdby},
success: function(response){
location.reload();
}
});
}
它不适合我在哪里出问题 如何解决它
我将一个用户的一些细节发送给其他人 如果接收者用户登录,则听取通知声音
答案 0 :(得分:0)
您需要将回应响应附加到某个元素。
首先,在html中创建一个元素。
<div id="audios" style="display:none;">We are audios!</div>
然后,在ajax中获取响应并在重新加载窗口之前将其附加到#audios。
$.ajax({
type: "post",
url: '<?php echo base_url();?>users/activetask',
cache: false,
data: {task: task,Task_id:Task_id,App_id:App_id,PhaseID:PhaseID,user_reciver_id:user_reciver_id,createdby:createdby},
success: function(response){
var audio_html = response;
$('#audios').append(audio_html);
location.reload();
}
});