2

当我尝试使用来自服务器的数据加载 Simile Timeline 时,我收到以下消息:

Failed to load json data from 
{"events":
[{
"description":"Oswald moves to New Orleans, and finds employment at the William B. Riley Coffee Company.",
"end":"Wed May 01 1969 00:00:00 GMT-0600",
"isDuration":true,
"start":"Wed May 01 1963 00:00:00 GMT-0600",
"title":"Oswald moves to New Orleans"}]}
Bad Request

我认为数据看起来是正确的。

这是触发请求的代码:

$(document).ready(function () {
        $.ajax({
            url: "http://localhost:64510/api/timeline",
            type: "GET",
            dataType: "json",
            contentType: "application/json",
            success: function (data) {
                loadTimeLine(data);
            }
        });

    });

function loadTimeLine(data) {

        var eventSource = new Timeline.DefaultEventSource();
        var bandInfos = [
            Timeline.createBandInfo({
                eventSource: eventSource,
                date: "Jun 28 2006 00:00:00 GMT",
                width: "70%",
                intervalUnit: Timeline.DateTime.MONTH,
                intervalPixels: 100
            }),
            Timeline.createBandInfo({
                eventSource: eventSource,
                date: "Jun 28 2006 00:00:00 GMT",
                width: "30%",
                intervalUnit: Timeline.DateTime.YEAR,
                intervalPixels: 200
            })
        ];
        bandInfos[1].syncWith = 0;
        bandInfos[1].highlight = true;


        tl = Timeline.create(document.getElementById("my-timeline"), bandInfos);

        Timeline.loadJSON(JSON.stringify(data), function (xml, url) { eventSource.loadJSON(xml, url); });

    }
4

1 回答 1

0

解决方案是您必须在从服务器创建响应时添加状态代码 200。

于 2012-09-23T19:25:04.367 回答