這篇文章主要介紹“怎么用ajax實現(xiàn)實時任務(wù)提示功能”,在日常操作中,相信很多人在怎么用ajax實現(xiàn)實時任務(wù)提示功能問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”怎么用ajax實現(xiàn)實時任務(wù)提示功能”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!

為沁水等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計制作服務(wù),及沁水網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為成都網(wǎng)站設(shè)計、成都網(wǎng)站制作、沁水網(wǎng)站設(shè)計,以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會得到認(rèn)可,從而選擇與我們長期合作。這樣,我們也可以走得更遠(yuǎn)!
項目代碼如下:
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
<?php
//設(shè)置正確的時區(qū)
date_default_timezone_set("Asia/Shanghai");
define('TASKOFPIG_DIR',dirname(__FILE__)) ;
require('../phplibs/FLEA/FLEA.php');
// 對$GLOBALS[G_FLEA_VAR]['CLASS_PATH'] 進(jìn)行配置
FLEA::import(TASKOFPIG_DIR); //將當(dāng)前目錄加入到環(huán)境變量中
FLEA::loadAppInf('appConfig.php') ; //將配置文件單獨分出來,容易維護
FLEA::init();
// 由于 FLEA_Db_TableDataGateway 并不是自動載入的,因此需要明確載入
FLEA::loadClass('FLEA_Db_TableDataGateway');
FLEA::runMVC();
?>
/ucren/taskofpig/appConfig.php
<?php
// 對 $GLOBALS[G_FLEA_VAR]['APP_INF'] 進(jìn)行配置
return array(
'dispatcher' => 'FLEA_Dispatcher_Simple' , //定制調(diào)度器 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( //定制數(shù)據(jù)庫連接參數(shù)
'driver' => 'MySQL',
'host' => 'localhost',
'login' => 'dbuser',
'password' => 'dbpass',
'database' => 'dbname' ,
'charset ' => 'utf8'
) ,
'logFileDir' => './log' , //定制日志
'logFilename' => 'task_admin.log'
);
?>
/ucren/taskofpig/Dao/Table.php
<?php
//生氣豬的任務(wù)計劃表
class Dao_TaskTable extends FLEA_Db_TableDataGateway
{
// 指定數(shù)據(jù)表名稱
var $tableName = 'task';
// 指定主鍵字段名
var $primaryKey = 'id';
}
?>
/ucren/taskofpig/Controller/Default.php
<?php
FLEA::loadFile('Dao_Table.php',true) ;
FLEA::loadFile('FLEA_Ajax_JSON.php',true) ;
class Controller_Default extends FLEA_Controller_Action
{
var $smarty ;
function Controller_Default()
{
$this->smarty = $this->_getView();
$this->smarty->assign('sitename','任務(wù)計劃表 -- 生氣豬') ;
$this->smarty->assign('opname','任務(wù)列表') ;//缺省應(yīng)該在子模塊中更改值
}
function actionIndex()
{
$this->toModulePage(); //缺省顯示任務(wù)列表頁
}
//定義一個函數(shù)用于調(diào)用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' ; //工具欄設(shè)置
$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(); //二維數(shù)組
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 "成功添加新任務(wù)";
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 "成功更新任務(wù)";
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'));
}
//任務(wù)流轉(zhuǎn)控制方法
function toModulePage()
{
if ($_REQUEST['op'] == 'search') {
$this->queryTaskForDate();
}
else if ($_REQUEST['op'] == 'add') {
$this->smarty->assign('opname','添加新任務(wù)') ;
$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','修改任務(wù)') ;
$this->_showPage('taskofpig.edit.html');
}
else { //列表
$this->listTask();
}
}
}
?>到此,關(guān)于“怎么用ajax實現(xiàn)實時任務(wù)提示功能”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>
新聞標(biāo)題:怎么用ajax實現(xiàn)實時任務(wù)提示功能
文章轉(zhuǎn)載:http://chinadenli.net/article2/ipdgic.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導(dǎo)航、云服務(wù)器、Google、建站公司、搜索引擎優(yōu)化、外貿(mào)網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)