我想嘗試通過ajax顯示我的通知json,但是當我嘗試先顯示未定義的,然後告訴我我的json我做錯了什麼?爲什麼當我點擊我的按鈕時,我不確定?
$(function (doc, win, $) {
var notification = win.Notification || win.mozNotification || win.webkitNotification;
var $badge = $("#notifications-badge");
var $list = $("#notifications-list");
var $button = $("#notifications-button");
URL_GET_NOTIFICATION = BASE_URL + 'notifications/getNotification';
function check_notifications() {
$.ajax({
type: 'GET',
url: URL_GET_NOTIFICATION,
//data: { timestamp : timestamp },
dataType: 'json',
async: true,
success: function (data) {
console.log(data);
}
});
}
$button.click(function (e) {
alert(check_notifications());
});
}(document, window, jQuery));
檢查通知功能沒有回調,這是我可以看到的唯一的問題 –
我該怎麼做? –