ajax實時任務(wù)提示功能的實現(xiàn)代碼
更新時間:2008年09月27日 17:54:13 作者:
本項目運用了 FLEAPHP,MYSQL,SMARTY,FCKEDItor,JSON,PROTOTYPE的技術(shù),在這里首先要感謝這些開源項目的開發(fā)者給我們帶來的好東西,其次要感謝[生氣豬--讓我?guī)退鲆粋€這樣的小東西來提醒她按時完成事情].花了一個3個小時完成.希望給大家起到拋磚引玉的作用啊....
/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ù)提示時間</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>提示時間: <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>提示時間: <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ù)提示腳本實現(xiàn),依賴于/ucren/prototype/prototype.js
var TaskTipAjax = function (){
this.desc = '按一定的時間間隔查詢數(shù)據(jù)庫中到期的事件信息,并給出提示[打開新窗口,播放一段音樂]' ;
}
//通過Ajax按時查詢和提示
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是一個對象
//task_obj.id task_obj.title task_obj.desc task_obj.date
var task_obj = json_parse(response.responseText);
var newwin=window.open('','任務(wù)報時器','height=200, width=600,toolbar=0,menubar=0,location=0, status=0');
newwin.opener = null // 防止代碼對論談頁面修改
//防止頁面內(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ù)報時器</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">時間</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
這個音樂 可以自己改
上面的代碼熟悉JAVA的應(yīng)該都可以看懂,這里只是要闡述一個簡單的設(shè)計方案,希望大家予以增加擴展功能,謝謝,發(fā)我郵件,或者留言.
我覺得軟件開發(fā)最重要的是開發(fā)思路,至于用什么語言實現(xiàn)倒是其次了,(*^__^*) 嘻嘻……
您可能感興趣的文章:
- ASP.NET搭配Ajax實現(xiàn)搜索提示功能
- jquery ajax請求方式與提示用戶正在處理請稍等
- php+ajax做仿百度搜索下拉自動提示框(有實例)
- ajax 自動完成下拉框 自動提示位置問題
- asp+ajax仿google搜索提示效果代碼
- 使用jQuery全局事件ajaxStart為特定請求實現(xiàn)提示效果的代碼
- ajax Suggest類似google的搜索提示效果
- jquery formValidator插件ajax驗證 內(nèi)容不做任何修改再離開提示錯誤的bug解決方法
- asp.net+js實現(xiàn)的ajax sugguest搜索提示效果
- Ajax實現(xiàn)智能提示搜索功能
相關(guān)文章
使用jquery 的ajax調(diào)用總是錯誤親測的解決方法
使用jquery 的ajax功能調(diào)用一個頁面,卻發(fā)現(xiàn)總是出現(xiàn)錯誤,經(jīng)過這么多測試終于正常了,尤其是 dataType: 'json',看來jquery有很嚴(yán)格的驗證機制2013-07-07js裝載xml文件然后發(fā)向服務(wù)器的實現(xiàn)代碼
js裝載xml文件然后發(fā)向服務(wù)器,具體的代碼可以參考下面的思路。2009-01-01添加后臺list給前臺select標(biāo)簽賦值簡單實現(xiàn)
本文為大家介紹下通過添加后臺list怎么實現(xiàn)給前臺select標(biāo)簽賦值,具體代碼如下,感興趣的朋友可以參考下哈2013-07-07Ajax上傳實現(xiàn)根據(jù)服務(wù)器端返回數(shù)據(jù)進行js處理的方法
這篇文章主要介紹了Ajax上傳實現(xiàn)根據(jù)服務(wù)器端返回數(shù)據(jù)進行js處理的方法,實例分析了Ajax請求及java處理并返回服務(wù)器端數(shù)據(jù)請求的相關(guān)技巧2015-07-07Ajax輪詢請求狀態(tài)(微信公眾號帶參數(shù)二維碼登錄網(wǎng)站)
最近做了一個項目,其中有功能要求通過掃碼微信公眾號帶參數(shù)的二維碼來登錄網(wǎng)站,接下來小編給大家介紹實現(xiàn)思路及代碼,一起看看吧2016-09-09