CHtml ajaxLink example01

本文介绍了一个使用PHP实现的音频通知设置功能,通过Ajax链接来触发后台获取并设置音频通知选项,包括默认音频与自定义音频的选择及显示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 1 <?php 
 2     $display=$MessageNotificationSwitch==1?'block':'none';
 3     echo CHtml::ajaxLink(
 4     $text = 'Edit Audio', 
 5     $url = $this->createUrl('companysetting/getOption',array('key'=>'MessageNotificationAudioId')), 
 6     $ajaxOptions=array (
 7         'type'=>'POST',
 8         'dataType'=>'json',
 9         'success'=>'function(data){
10             if(typeof(data)!=="undefined"){
11                 if(parseInt(data.option_value)==1){
12                     $("input[name=MessageNotificationType]:eq(0)").attr("checked","checked");
13                     $("#MessageNotificationImport").hide();
14                     $("#MessageNotificationDefault").show();
15                 }else{
16                     $("input[name=MessageNotificationType]:eq(1)").attr("checked","checked");
17                     $("#MessageNotificationImport").show();
18                     $("#MessageNotificationDefault").hide();
19                 }
20                 $.post("'.$this->createUrl('companysetting/getOption',array('key'=>'MessageNotificationCustom')).'",{},function(data){
21                     if(typeof(data)!=="undefined"){
22                         if(data.option_value!=="" || data.option_value==null){
23                             $("#MessageNotificationImportPlay").show();
24                             bindVoice("jp_mn_1","jp_mn_c_1","/audio/personalization/default/message_notification.wav");
25                             bindVoice("jp_mn_2","jp_mn_c_2",data.option_value);
26                         }else{
27                             $("#MessageNotificationImportPlay").hide();
28                         }
29                     }
30                 },"json");
31                 $("#MessageNotificationWindow").dialog("open");
32             }
33         }'
34     ), 
35     $htmlOptions=array('style'=>"display:$display;",'id'=>'MessageNotificationCustomWindow')
36     );
37 ?>

转载于:https://www.cnblogs.com/sexy/articles/3865660.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值