0
通知をページに表示したいので、AJAX getメソッドを含むwindow.setinterval関数を使用しました。jquery ajaxを使用して通知が表示されない
header.asp
window.setInterval(function() {
$.ajax({
url: 'getnotifications.asp',
type: 'GET',
dataType: 'javascript',
cache: false,
success: function(data) {
\t \t \t return data;
}
});
}, 10000);
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 %>
\t \t \t <script>
\t \t \t $(window).load(function() {
$.growl.notice({ message: "The kitten is cute! hahaha" });
\t \t });
\t \t </script>
\t \t <%
\t rsGetLatestNotifications.MoveNext
Loop
rsGetLatestNotifications.Close
Set rsGetLatestNotifications = Nothing
adoConNotificationsData.Close
Set adoConNotificationsData = Nothing
adoConSiteData.Close
Set adoConSiteData = Nothing
adoConMemData.Close
Set adoConMemData = Nothing
%> \t
コードが機能せず、何かが見つからないことがわかりました! plsあなたが私を助けてくれてありがとうございます
JSONを使ってみると、もっと簡単です:https://code.google.com/archive/p/aspjson/ –