[英]notifications don't show up using jquery ajax get
i want to display the notifications on a page, so i used window.setinterval function that contains an AJAX get method ! 我想在页面上显示通知,所以我使用了包含AJAX get方法的window.setinterval函数!
header.asp header.asp
window.setInterval(function() { $.ajax({ url: 'getnotifications.asp', type: 'GET', dataType: 'javascript', cache: false, success: function(data) { return data; } }); }, 10000);
getnotifications.asp getnotifications.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <% Response.Charset="UTF-8" %> <!--#INCLUDE file="connect/site_conn.asp" --> <!--#INCLUDE file="connect/members_conn.asp" --> <!--#INCLUDE file="connect/notifications_conn.asp" --> <!--#INCLUDE file="global.asp" --> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script src="js/jquery.growl.js" type="text/javascript"></script> <link href="css/jquery.growl.css" rel="stylesheet" type="text/css" /> <% Dim rsGetLatestNotifications Set rsGetLatestNotifications = Server.CreateObject("ADODB.Recordset") strSQLData = "SELECT * FROM TB_NOTIFICATIONS WHERE NOT_TO = " & mem_id & " AND NOT_READ = false" strSQLData = "" & strSQLData & ";" rsGetLatestNotifications.CursorType = 2 rsGetLatestNotifications.LockType = 3 rsGetLatestNotifications.Open strSQLData, adoConNotificationsData Do While not rsGetLatestNotifications.EOF %> <script> $( window ).load(function() { $.growl.notice({ message: "The kitten is cute! hahaha" }); }); </script> <% rsGetLatestNotifications.MoveNext Loop rsGetLatestNotifications.Close Set rsGetLatestNotifications = Nothing adoConNotificationsData.Close Set adoConNotificationsData = Nothing adoConSiteData.Close Set adoConSiteData = Nothing adoConMemData.Close Set adoConMemData = Nothing %>
the code doesn't work and i know something is missing ! 该代码不起作用,我知道有些东西丢失了! pls i'll be grateful if you help me
如果您能帮助我,我将不胜感激
<% Dim member Set JSONdata= jsObject()
Do While not rsGetLatestNotifications.EOF %>
JSONdata("message") = "The kitten is cute! hahaha"
rsGetLatestNotifications.MoveNext
Loop
JSONdata.Flush
%>
window.setInterval(function() {
$.ajax({
url: 'getnotifications.asp',
type: 'GET',
dataType: 'json',
cache: false,
success: function(JSONdata) {
$.growl.notice(JSONdata);
}
});
}, 10000);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.