怎么用ajax实现实时任务提示功能
这篇文章主要介绍“怎么用ajax实现实时任务提示功能”,在日常操作中,相信很多人在怎么用ajax实现实时任务提示功能问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”怎么用ajax实现实时任务提示功能”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
为沁水等地区用户提供了全套网页设计制作服务,及沁水网站建设行业解决方案。主营业务为成都网站设计、成都网站制作、沁水网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!
项目代码如下:
db.sql SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for task -- ---------------------------- CREATE TABLE `task` ( `id` int(11) NOT NULL, `title` varchar(100) collate utf8_unicode_ci NOT NULL, `desc` text collate utf8_unicode_ci, `date` datetime NOT NULL, `created` int(11) default NULL, `updated` int(11) default NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- ---------------------------- -- Table structure for task_seq -- ---------------------------- CREATE TABLE `task_seq` ( `id` int(11) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /ucren/taskofpig/index.php /ucren/taskofpig/appConfig.php 'FLEA_Dispatcher_Simple' , //定制调度器 FLEA_Dispatcher_Auth 'controllerAccessor' => 'ctl' , 'actionAccessor' => 'act' , 'view' => 'FLEA_View_Smarty', //定制视图 'viewConfig' => array( 'smartyDir' => '../phplibs/Smarty', 'template_dir' => './tpl', 'compile_dir' => './tpl_c', 'left_delimiter' => '<%', 'right_delimiter' => '%>', 'debugging' => false ), 'dbDSN' => array( //定制数据库连接参数 'driver' => 'MySQL', 'host' => 'localhost', 'login' => 'dbuser', 'password' => 'dbpass', 'database' => 'dbname' , 'charset ' => 'utf8' ) , 'logFileDir' => './log' , //定制日志 'logFilename' => 'task_admin.log' ); ?> /ucren/taskofpig/Dao/Table.php /ucren/taskofpig/Controller/Default.php smarty = $this->_getView(); $this->smarty->assign('sitename','任务计划表 -- 生气猪') ; $this->smarty->assign('opname','任务列表') ;//缺省应该在子模块中更改值 } function actionIndex() { $this->toModulePage(); //缺省显示任务列表页 } //定义一个函数用于调用FCKeditor function call_fck($input_name,$input_value,$w='800',$h='400') { include_once '../fckeditor/fckeditor.php'; $fcked = new FCKeditor($input_name) ; $fcked->BasePath = '../fckeditor/'; $fcked->ToolbarSet = 'Default' ; //工具栏设置 $fcked->InstanceName = $input_name ; $fcked->Width = $w; $fcked->Height = $h; $fcked->Value = $input_value; $fck_area = $fcked->CreateHtml(); $this->smarty->assign('fck_area',$fck_area); unset($fck_area) ; unset($fcked) ; } function _showPage($tpl='taskofpig.main.html') { $this->smarty->display($tpl); } function actionAdd() { $this->addTask(); } function actionUpdate() { $this->updateTask(); } function deleteTask($id){ $row = array('id'=>$id); $thisDao = & new Dao_TaskTable() ; $status = $thisDao->remove($row); //返回boolean值 unset($thisDao); return $status ; } function listTask() { $thisDao = & new Dao_TaskTable() ; $rows = $thisDao->findAll(); //二维数组 foreach($rows as &$row) //注意这里要传引用 { $row['desc'] = mb_substr($row['desc'],0,40,'UTF-8'); } $this->smarty->assign('rowSet',$rows); $this->_showPage(); } function addTask() { $thisDao = & new Dao_TaskTable() ; $row = array( 'title' => $_REQUEST['title'], 'desc' => $_REQUEST['desc'], 'date' => $_REQUEST['date'] ); $commitId = $thisDao->create($row); unset($thisDao); echo "成功添加新任务"; redirect( url("Default"),1) ; } function updateTask() { $thisDao = & new Dao_TaskTable() ; $row = array( 'id' => $_REQUEST['id'], 'title' => $_REQUEST['title'], 'desc' => $_REQUEST['desc'], 'date' => $_REQUEST['date'] ); $commitId = $thisDao->update($row); unset($thisDao); echo "成功更新任务"; redirect( url("Default"),1) ; } function queryTask($id){ $thisDao = & new Dao_TaskTable() ; $row = $thisDao->find(array('id'=>$id)); unset($thisDao); return $row ; } function queryTaskForDate($date=null) { $thisDao = & new Dao_TaskTable() ; //'2008-08-17 07:42:29' $row = $thisDao->find(array('date'=>date('Y-m-d H:i:s'))); unset($thisDao); if (!empty($row)) { $jsonobj = new Services_JSON(); echo $jsonobj->encode($row); } else die(date('Y-m-d H:i:s')); } //任务流转控制方法 function toModulePage() { if ($_REQUEST['op'] == 'search') { $this->queryTaskForDate(); } else if ($_REQUEST['op'] == 'add') { $this->smarty->assign('opname','添加新任务') ; $this->smarty->assign('taskTime',date('Y-m-d H:i:s')) ; $this->call_fck('desc',''); $this->_showPage('taskofpig.add.html'); } else if ($_REQUEST['op'] == 'del') { if ( isset($_REQUEST['id']) && is_numeric($_REQUEST['id']) ) $status = $this->deleteTask($_REQUEST['id']) ; $this->listTask(); } else if ($_REQUEST['op'] == 'edit') { if ( isset($_REQUEST['id']) && is_numeric($_REQUEST['id']) ){ $row = $this->queryTask($_REQUEST['id']) ; } $this->call_fck('desc',$row['desc']); unset($row['desc']) ; $this->smarty->assign('rowSet',$row); $this->smarty->assign('opname','修改任务') ; $this->_showPage('taskofpig.edit.html'); } else { //列表 $this->listTask(); } } } ?>
到此,关于“怎么用ajax实现实时任务提示功能”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注创新互联网站,小编会继续努力为大家带来更多实用的文章!
新闻标题:怎么用ajax实现实时任务提示功能
文章出自:http://azwzsj.com/article/ipdgic.html