我正在使用PHP設置在線診所註冊系統。該系統有兩個不同的用戶組,即患者和診所。患者將從可用的診所中進行選擇,並在註冊後向患者發放唯一的隊列號。我已經做了所有這些,但是我現在需要知道的是,如何在患者用戶收到新註冊時爲診所用戶創建警報?此警報將通知診所新的註冊而不刷新網頁。註冊後向選定的用戶創建警報
0
A
回答
0
使用Ajax從服務器獲取最新(或未讀)通知。該Ajax可以定期從登錄的診所用戶的瀏覽器發送。
如果診所不在線,您也可以通過電子郵件向診所發送電子郵件。
0
我會用「XMLHttpRequest」來做到這一點。在診所的網頁,我會的JavaScript是這樣的:
<script type="text/javascript">
var comm = new Array(), frameTime = 0, regTime = 0;
function startItUp(){
animate();
}
window.requestAnimFrame = (function(){//from Paul Irish
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(callback, element){
window.setTimeout(callback, 1000/60);
};
})();
function animate() {
frameTime = Date.now();
if(regTime < frameTime){
comm.push(new getRegistrants());
regTime = frameTime + 8000;//how often to call the php page and check for new patients
}
}
requestAnimFrame(animate);
}
function getRegistrants(){
this.client = new XMLHttpRequest();
this.client.onload = function() {
var registrantData = this.responseText;
//Parse the registrant data displayed by php page here and make the alert or div popup...
alert(parsedRegistrantName + ' has registered.');
}
this.client.open('POST', 'getRegistrants.php');//This page would have a session that would contain your logged in clinic's ID and would just output registrant(patient) data that you can parse
this.client.send();
}
</script>
然後在診所的網頁來啓動它:
<body onload="startItUp();">
注:此方法已經在幾個網站appliations但工作對我很好,從我個人的經驗來看,如果你有很多診所(幾百個說法)執行XMLHttpRequest,那麼如果你有便宜/共同的共享主機,你將遇到服務器資源問題。
相關問題
- 1. 註冊後Laravel oauth用戶重定向
- 2. Laravel 5.3註冊後重定向用戶
- 3. 註冊後創建匿名用戶cookie
- 4. 註冊後自動創建用戶
- 5. 註冊後註冊用戶
- 6. 註冊後重定向
- 7. 註冊後Gluu重定向
- 8. 重定向註冊後
- 9. Facebook註冊後重定向
- 10. Yii的重定向到用戶/註冊
- 11. 如何在註冊流星後創建沒有自動註冊的用戶
- 12. 使用Devise&Omniauth註冊後重定向
- 13. 如何創建用戶註冊頁面
- 14. 用戶註冊時創建子域名
- 15. 用戶註冊時創建MySQL表
- 16. 如何在使用Devise時註冊後重定向用戶?
- 17. 在官方「警報」列表中註冊警報?
- 18. 設計註冊後重定向,但用戶未登錄
- 19. 如何在公寓寶石註冊後重定向用戶
- 20. 註冊後重定向用戶時出現問題
- 21. 如何在Woocommerce註冊後重定向用戶?
- 22. 如何在用戶註冊後根據單選按鈕重定向
- 23. 如何在註冊期間爲用戶創建特定的URL?
- 24. asp.net嚮導控件創建註冊
- 25. Omniauth Facebook重定向到註冊屏幕而不是創建用戶
- 26. Django註冊 - 成功登錄後從登錄/註冊重定向
- 27. ASP.NET MVC結賬註冊後重定向
- 28. Laravel 5 - 註冊後重定向到URL
- 29. 在Drupal中註冊後重定向
- 30. 創建註冊碼
您可能需要使用ajax。 – Pitchinnate 2013-03-18 15:31:37