ajax實(shí)時(shí)任務(wù)提示功能的實(shí)現(xiàn)代碼第2/2頁(yè)
更新時(shí)間:2008年09月27日 17:54:13 作者:
本項(xiàng)目運(yùn)用了 FLEAPHP,MYSQL,SMARTY,FCKEDItor,JSON,PROTOTYPE的技術(shù),在這里首先要感謝這些開源項(xiàng)目的開發(fā)者給我們帶來(lái)的好東西,其次要感謝[生氣豬--讓我?guī)退鲆粋€(gè)這樣的小東西來(lái)提醒她按時(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ù)中到期的事件信息,并給出提示[打開新窗口,播放一段音樂(lè)]' ;
}
//通過(guò)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è)音樂(lè) 可以自己改
上面的代碼熟悉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)提示位置問(wèn)題
- 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)文章
ajax智能提示+textbox動(dòng)態(tài)生成下拉框示例代碼
ajax智能提示+textbox動(dòng)態(tài)生成下拉框,下面有個(gè)不錯(cuò)的示例,感興趣的朋友可以參考下,希望對(duì)大家有所幫助2013-12-12
Ajax Control Toolkit 34個(gè)服務(wù)器端控件
Ajax Control Toolkit 34個(gè)服務(wù)器端控件,想要學(xué)習(xí)ajax的朋友可以參考下。2009-09-09
IE9下Ajax無(wú)法刷新數(shù)據(jù)的緩存問(wèn)題解決方法
使用jQuery的getJSON從后臺(tái)定時(shí)獲取數(shù)據(jù)并刷新界面,在IE9下卻無(wú)法刷新數(shù)據(jù),原因就是緩存的問(wèn)題,下面是解決方法2014-09-09
實(shí)例代碼講解ajax實(shí)現(xiàn)的無(wú)刷新分頁(yè)
這篇文章主要介紹了實(shí)例代碼講解ajax實(shí)現(xiàn)的無(wú)刷新分頁(yè)的相關(guān)資料,需要的朋友可以參考下2015-12-12
Ajax向后臺(tái)傳json格式的數(shù)據(jù)出現(xiàn)415錯(cuò)誤的原因分析及解決方法
ajax往后臺(tái)傳json格式數(shù)據(jù)報(bào)415錯(cuò)誤,什么原因?qū)е碌哪?,該怎么解決呢?下面腳本之家小編給大家?guī)?lái)了Ajax向后臺(tái)傳json格式的數(shù)據(jù)出現(xiàn)415錯(cuò)誤的原因分析及解決方法感興趣的朋友一起看看吧
2016-10-10
Ajax實(shí)現(xiàn)動(dòng)態(tài)加載數(shù)據(jù)
這篇文章主要為大家詳細(xì)介紹了Ajax動(dòng)態(tài)加載數(shù)據(jù)的小例子,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
2017-05-05 
