通过 Javascript (RDF4J Server REST API) 查询 GraphDB 时指定结果 MIME 类型

Specifying result MIME type when querying GraphDB via Javascript (RDF4J Server REST API)

我正在尝试使用 Javascript 查询 GraphDB 存储库。这是代码:

var SPARQLendpoint = {

    getData: function (query) {

        var endpointUrl = 'http://localhost:7200/repositories/myRepo',

            settings = {
                headers: { Accept: 'application/sparql-results+json'},
                data: { query: query },
                dataType: 'jsonp'
            };

        $.ajax(endpointUrl, settings).then(function (data) {
            $('body').append(($('<pre>').text(JSON.stringify(data))));
            console.log(data);
        });

    });

    }

}
query = 'here is the query';
SPARQLendpoint.getData(query);

但是我得到这个错误:

Refused to execute script from 'http://localhost:7200/repositories/myRepo?callback=jQuery321005935533972872964_1529595202948&query=...' because its MIME type ('text/csv') is not executable.

如果我通过 Chrome 的开发者工具检查请求,我可以在“应用程序”选项卡下看到预期的 CSV 序列化结果集(!?)

有没有办法告诉 GraphDB/RDF4J 将结果集序列化为 JSON 或在 ajax 请求中管理此类 CSV 序列化?

通过使用 -Dgraphdb.workbench.cors.enable=true 启动 graphDB 并从 JS 代码中删除 dataType: 'jsonp' 解决