【问题标题】:Fullcalendar with node js & mysql带有节点 js 和 mysql 的完整日历
【发布时间】:2018-03-01 08:57:49
【问题描述】:

我想用 node js、mysql 和 express 创建一个日历。 这是我的 Calendar.js 代码:

$(document).ready(function() {
    $('#calendar').fullCalendar({
        theme: true,
        eventLimit: true,
        eventSources: [source]
    });
});

我在文件 bdCalendar.js 中有 bd mysql“事件”表和数据。我不明白如何使用节点 js 将数据从表传输到数组源?

bdCalendar.js:

const mysql = require('mysql');
var bdCalendar = mysql.createConnection({
    host: 'localhost',
    user: 'admin',
    password: 'admin',
    database: 'event_calendar'
});
bdCalendar.connect((err) => {
    if (err) throw err;
    console.log('Connected');
});

bdCalendar.query("SELECT * FROM event", function(err, rows) {
    if (err) {
        throw err;
    } else {
        console.log(rows)
    }
 }
});

module.exports = bdCalendar;

我会很高兴有你的帮助!!!

【问题讨论】:

  • 您的代码中的[source] 是什么? source 是指向 nodeJS 服务器上的 URL 端点的变量吗? fullCalendar 只是使用它通过 ajax 向端点发出 HTTP 请求(传递您的服务器应该用来过滤返回事件列表的开始和结束日期),并且它期望以 fullCalendar 中描述的 JSON 格式返回响应文档。就像任何其他 ajax 请求一样,真的。您是否在节点中创建了端点?如果您不知道怎么做,请学习 nodeJS 教程。

标签: jquery mysql node.js express fullcalendar


【解决方案1】:

您必须有一个用 node.js 编写的 API 端点,可能使用 Express 框架。 Fullcalendar 正在向该端点发出 AJAX 请求,您获取事件并将列表发回。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-01
    • 1970-01-01
    • 2012-09-30
    • 2012-12-18
    相关资源
    最近更新 更多