d3及;jquery返回text/plain而不是text/xml

d3及;jquery返回text/plain而不是text/xml,jquery,d3.js,nginx,Jquery,D3.js,Nginx,我试图实现d3示例,与修改之前在github上的实现完全一样。我所做的唯一更改是将文件放在我的nginx服务器中,并更改airlines.xml文件的位置 因此,我和原始html(参见上面的github)之间唯一的区别代码是xml位置行: d3.xml("http://localhost/CH_Viz/example/bundling_data/airlines.xml", function(xml) { //Transform the XML data into a proper fo

我试图实现d3示例,与修改之前在github上的实现完全一样。我所做的唯一更改是将文件放在我的nginx服务器中,并更改airlines.xml文件的位置

因此,我和原始html(参见上面的github)之间唯一的区别代码是xml位置行:

d3.xml("http://localhost/CH_Viz/example/bundling_data/airlines.xml", function(xml) {
    //Transform the XML data into a proper format used by the algorithm
    var raw_edges = xml.documentElement.getElementsByTagName("edge"); 
当我尝试此操作时,raw_edges行给出以下错误:“uncaughttypeerror:无法读取null的属性'documentElement'”

但我可以通过键入代码中使用的url来访问该文件。它似乎与MIME类型有关(与问题类似),但我不知道如何使用它们。我注意到,在javascript控制台的网络面板中,我尝试的airlines.xml的类型是text/plain,而工作版本中的类型是application/xml

我的nginx服务器具有text/xml mime类型,但不是application/xml类型。我尝试删除text/xml并用application/xml替换它,然后重新启动nginx,但没有帮助:(


非常感谢您的帮助!

您是否尝试记录xml,如在
console.log(xml)
中检查过?这意味着它找不到url。请尝试将http://…更改为“/bundling\u data/airlines.xml”。这假设您的index.html文件位于/example/folder中,将其更改为“/bundling\u data/airliner.xml”给出了相同的错误,我仍然可以在javascript控制台的网络部分看到该文件显示为text/plain。我也可以预览该文件,只是无法识别它。我也尝试了console.log(xml)功能,但没有得到比“xml未定义”更有用的帮助。也尝试将xml位更改为文件位置,但无效。