Php 使用Ajax时FullCalendar返回错误
我在这里搜索了有关Fullcalendar的几乎所有相关错误 我有一个JQuery,它来自于这个文档 但每当我尝试运行此代码时,它不会在我的日历中返回任何内容,并且在控制台中会出现此错误Php 使用Ajax时FullCalendar返回错误,php,jquery,ajax,fullcalendar,Php,Jquery,Ajax,Fullcalendar,我在这里搜索了有关Fullcalendar的几乎所有相关错误 我有一个JQuery,它来自于这个文档 但每当我尝试运行此代码时,它不会在我的日历中返回任何内容,并且在控制台中会出现此错误 VM8547 jquery-2.2.3.min.js:2 Uncaught Error: Syntax error, unrecognized expression: { "event": [ { "title": "test 1",
VM8547 jquery-2.2.3.min.js:2 Uncaught Error: Syntax error, unrecognized
expression:
{
"event": [
{
"title": "test 1",
"start": "2015-10-20",
"end": "2015-10-20"
},
{
"title": "test 2",
"start": "2016-04-18",
"end": "2016-04-18"
},
{
"title": "test 3",
"start": "2017-07-22",
"end": "2017-07-22"
},
{
"title": "test 4",
"start": "0000-00-00",
"end": "0000-00-00"
},
{
"title": "test 5",
"start": "2015-08-26",
"end": "2015-08-26"
},
{
"title": "test 6",
"start": "0000-00-00",
"end": "0000-00-00"
},
{
"title": "test 7",
"start": "2018-01-10",
"end": "2018-01-10"
},
{
"title": "8",
"start": "2018-07-09",
"end": "2018-07-09"
},
{
"title": "test 9",
"start": "2018-05-28",
"end": "2018-05-28"
},
{
"title": "test 10",
"start": "2016-03-10",
"end": "2016-03-10"
}
]
}
at Function.fa.error (VM8547 jquery-2.2.3.min.js:2)
at fa.tokenize (VM8547 jquery-2.2.3.min.js:2)
at fa.select (VM8547 jquery-2.2.3.min.js:2)
at Function.fa [as find] (VM8547 jquery-2.2.3.min.js:2)
at n.fn.init.find (VM8547 jquery-2.2.3.min.js:2)
at new n.fn.init (VM8547 jquery-2.2.3.min.js:2)
at n (VM8547 jquery-2.2.3.min.js:2)
at Object.success (?page=test-kim:1882)
at i (VM8547 jquery-2.2.3.min.js:2)
at Object.fireWith [as resolveWith] (VM8547 jquery-2.2.3.min.js:2)
我在这里找不到问题。我试着读了几乎所有我能找到的补丁,但没有任何效果 没关系,我通过不使用ajax修复了它,以防有人需要它
$('#calendar').fullCalendar({
eventSources: [
{
url: 'api/test.php'
}
]
});
您如何定义回调?@cid对不起,您的意思是什么?我如何定义?这是我的大部分代码。除非您的端点返回特定结构中的XML(如示例中您从逐字复制而来的XML),否则它将不可避免地无法正确处理响应。如果服务器返回的JSON已经是fullCalendar识别的格式,那么您不需要执行文档中所示的任何客户端处理。(另外,我从你下面的回答中意识到你已经找到了一个解决方案,但从你的回答中不清楚你是否意识到你的改变为什么奏效。)
$('#calendar').fullCalendar({
eventSources: [
{
url: 'api/test.php'
}
]
});