ajax實(shí)時(shí)任務(wù)提示功能的實(shí)現(xiàn)代碼
更新時(shí)間:2008年09月27日 17:54:13 作者:
本項(xiàng)目運(yùn)用了 FLEAPHP,MYSQL,SMARTY,FCKEDItor,JSON,PROTOTYPE的技術(shù),在這里首先要感謝這些開源項(xiàng)目的開發(fā)者給我們帶來的好東西,其次要感謝[生氣豬--讓我?guī)退鲆粋€(gè)這樣的小東西來提醒她按時(shí)完成事情].花了一個(gè)3個(gè)小時(shí)完成.希望給大家起到拋磚引玉的作用啊....
/ucren/taskofpig/tpl/taskofpig.main.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><%$sitename%> -- <%$opname%></title>
<script type="text/javascript" src="/ucren/prototype/prototype.js"></script>
<script type="text/javascript" src="/ucren/json/json_parse.js"></script>
<script type="text/javascript" src="js/tasktip.js"></script>
</head>
<body>
<bgsound>
<div>
<span id='task_attime'></span>
</div>
<hr>
<p>
<span onClick="document.location='index.php?op=add'">添加</span> |
<span onClick="document.location='index.php?op=search'">查看任務(wù)提示</span> |
</p>
<hr>
<hr>
<table width="90%" border="1" cellspacing="1" bgcolor="#cfdadc">
<tr bgcolor="#e8edec" align="center">
<td><b>ID</b></td>
<td><b>主題</b></td>
<td><b>任務(wù)內(nèi)容</b></td>
<td><b>任務(wù)提示時(shí)間</b></td>
<td colspan="2"><b>管理</b></td>
</tr>
<%section name=rowIndex loop=$rowSet%>
<tr align="center">
<td><%$rowSet[rowIndex].id%></td>
<td><%$rowSet[rowIndex].title%></td>
<td><%$rowSet[rowIndex].desc%></td>
<td><%$rowSet[rowIndex].date%></td>
<td onClick="document.location='index.php?op=edit&id=<%$rowSet[rowIndex].id%>'"><b>編輯</b></td>
<td onClick="document.location='index.php?op=del&id=<%$rowSet[rowIndex].id%>'"><b>刪除</b></td>
</tr>
<%/section%>
</table>
</body>
</html>
/ucren/taskofpig/tpl/taskofpig.edit.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><%$sitename%> -- <%$opname%></title>
</head>
<body bgcolor="e8edec">
<div align="center">
<form method="post" action="index.php?&act=update&id=<%$rowSet.id%>">
<table width="80%" border="1" cellspacing="1" bgcolor="#cfdadc">
<tr bgcolor="e8edec">
<td>任務(wù)標(biāo)題: <input name="title" type="text" size="80" value="<%$rowSet.title%>"></td>
</tr>
<tr bgcolor="e8edec">
<td>提示時(shí)間: <input name="date" type="text" size="40" value="<%$rowSet.date%>"></td>
</tr>
<tr bgcolor="e8edec">
<td class="forumRow">任務(wù)內(nèi)容<%$fck_area%></td>
</tr>
</table>
<input type="submit" value="提交">
<input type="button" value="返回" onclick="document.location='index.php'">
</form>
</div>
</body>
</html>
/ucren/taskofpig/tpl/taskofpig.add.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><%$sitename%> -- <%$opname%></title>
</head>
<body bgcolor="e8edec">
<div align="center">
<form method="post" action="index.php?&act=add">
<table width="80%" border="1" cellspacing="1" bgcolor="#cfdadc">
<tr bgcolor="e8edec">
<td>任務(wù)標(biāo)題: <input name="title" type="text" size="80" ></td>
</tr>
<tr bgcolor="e8edec">
<td>提示時(shí)間: <input name="date" type="text" size="40" value="<%$taskTime%>"></td>
</tr>
<tr bgcolor="e8edec">
<td class="forumRow">任務(wù)內(nèi)容<%$fck_area%></td>
</tr>
</table>
<input type="submit" name="Submit" value="提交">
<input type="reset" name="Submit3" value="重設(shè)">
</form>
</div>
</body>
</html>
/ucren/taskofpig/js/tasktip.js
//任務(wù)提示腳本實(shí)現(xiàn),依賴于/ucren/prototype/prototype.js
var TaskTipAjax = function (){
this.desc = '按一定的時(shí)間間隔查詢數(shù)據(jù)庫(kù)中到期的事件信息,并給出提示[打開新窗口,播放一段音樂]' ;
}
//通過Ajax按時(shí)查詢和提示
TaskTipAjax.prototype.doAction = function(obj)
{
var myAjax = new Ajax.Request(
'index.php?op=search' ,
{
method: 'get' ,asynchronous: true ,
onComplete: obj.showResponse
}
) ;
}
TaskTipAjax.prototype.showResponse = function (response)
{
if (response.responseText != '')
{
//此方法在/ucren/json/json_parse.js中定義
//task_obj是一個(gè)對(duì)象
//task_obj.id task_obj.title task_obj.desc task_obj.date
var task_obj = json_parse(response.responseText);
var newwin=window.open('','任務(wù)報(bào)時(shí)器','height=200, width=600,toolbar=0,menubar=0,location=0, status=0');
newwin.opener = null // 防止代碼對(duì)論談頁(yè)面修改
//防止頁(yè)面內(nèi)容重復(fù)
if( typeof(newwin.document.body) != "undefined")
newwin.document.body.innerHTML = "";
newwin.document.write("<html><body><bgsound src='music/moonlight.mp3' autostart=true loop=infinite>");
newwin.document.write('<h1>任務(wù)報(bào)時(shí)器</h1><br/>');
newwin.document.write('<table border="1">');
newwin.document.write('<tr>');
newwin.document.write('<td width="33" bgcolor="#E8E8E8">ID</td>');
newwin.document.write('<td width="33" bgcolor="#E8E8E8">標(biāo)題</td>');
newwin.document.write('<td width="33" bgcolor="#E8E8E8">描述</td>');
newwin.document.write('<td width="33" bgcolor="#E8E8E8">時(shí)間</td>');
newwin.document.write('</tr>');
newwin.document.write('<tr>');
newwin.document.write('<td>'+ task_obj.id +'</td>');
newwin.document.write('<td>'+ task_obj.title +'</td>');
newwin.document.write('<td>'+ task_obj.desc +'</td>');
newwin.document.write('<td>'+ task_obj.date +'</td>');
newwin.document.write('</tr>');
newwin.document.write('</table>');
newwin.document.write("</body></html>");
//置頂
newwin.focus();
}
}
var obj = new TaskTipAjax();
setInterval("obj.doAction(obj)",1000) ;
/ucren/taskofpig/music/moonlight.mp3
這個(gè)音樂 可以自己改
上面的代碼熟悉JAVA的應(yīng)該都可以看懂,這里只是要闡述一個(gè)簡(jiǎn)單的設(shè)計(jì)方案,希望大家予以增加擴(kuò)展功能,謝謝,發(fā)我郵件,或者留言.
我覺得軟件開發(fā)最重要的是開發(fā)思路,至于用什么語(yǔ)言實(shí)現(xiàn)倒是其次了,(*^__^*) 嘻嘻……
您可能感興趣的文章:
- ASP.NET搭配Ajax實(shí)現(xiàn)搜索提示功能
- jquery ajax請(qǐng)求方式與提示用戶正在處理請(qǐng)稍等
- php+ajax做仿百度搜索下拉自動(dòng)提示框(有實(shí)例)
- ajax 自動(dòng)完成下拉框 自動(dòng)提示位置問題
- asp+ajax仿google搜索提示效果代碼
- 使用jQuery全局事件ajaxStart為特定請(qǐng)求實(shí)現(xiàn)提示效果的代碼
- ajax Suggest類似google的搜索提示效果
- jquery formValidator插件ajax驗(yàn)證 內(nèi)容不做任何修改再離開提示錯(cuò)誤的bug解決方法
- asp.net+js實(shí)現(xiàn)的ajax sugguest搜索提示效果
- Ajax實(shí)現(xiàn)智能提示搜索功能
相關(guān)文章
使用jquery 的ajax調(diào)用總是錯(cuò)誤親測(cè)的解決方法
使用jquery 的ajax功能調(diào)用一個(gè)頁(yè)面,卻發(fā)現(xiàn)總是出現(xiàn)錯(cuò)誤,經(jīng)過這么多測(cè)試終于正常了,尤其是 dataType: 'json',看來jquery有很嚴(yán)格的驗(yàn)證機(jī)制2013-07-07js裝載xml文件然后發(fā)向服務(wù)器的實(shí)現(xiàn)代碼
js裝載xml文件然后發(fā)向服務(wù)器,具體的代碼可以參考下面的思路。2009-01-01添加后臺(tái)list給前臺(tái)select標(biāo)簽賦值簡(jiǎn)單實(shí)現(xiàn)
本文為大家介紹下通過添加后臺(tái)list怎么實(shí)現(xiàn)給前臺(tái)select標(biāo)簽賦值,具體代碼如下,感興趣的朋友可以參考下哈2013-07-07Ajax上傳實(shí)現(xiàn)根據(jù)服務(wù)器端返回?cái)?shù)據(jù)進(jìn)行js處理的方法
這篇文章主要介紹了Ajax上傳實(shí)現(xiàn)根據(jù)服務(wù)器端返回?cái)?shù)據(jù)進(jìn)行js處理的方法,實(shí)例分析了Ajax請(qǐng)求及java處理并返回服務(wù)器端數(shù)據(jù)請(qǐng)求的相關(guān)技巧2015-07-07Ajax+PHP簡(jiǎn)單基礎(chǔ)入門實(shí)例教程
Ajax 由 HTML、JavaScript™ 技術(shù)、DHTML 和 DOM 組成,這一杰出的方法可以將笨拙的 Web 界面轉(zhuǎn)化成交互性的 Ajax 應(yīng)用程序。對(duì)于Ajax,最核心的一個(gè)對(duì)象是XMLHttpRequest,所有的ajax操作都離不開對(duì)這個(gè)對(duì)象的操作。2008-12-12Ajax輪詢請(qǐng)求狀態(tài)(微信公眾號(hào)帶參數(shù)二維碼登錄網(wǎng)站)
最近做了一個(gè)項(xiàng)目,其中有功能要求通過掃碼微信公眾號(hào)帶參數(shù)的二維碼來登錄網(wǎng)站,接下來小編給大家介紹實(shí)現(xiàn)思路及代碼,一起看看吧2016-09-09