JS中调用后缀名为json的文件出错:ERROR 404.3 Not Found for JSON file
我们在使用前台插件的时候,demo中的JS会调用后缀名为json的文件,作为json数据传输给页面,例如下面的FacyTree中的Demo
$("#tree").fancytree({ extensions: ["dnd", "edit", "glyph", "wide"], checkbox: true, dnd: { focusOnClick: true, dragStart: function(node, data) { return true; }, dragEnter: function(node, data) { return false; }, dragDrop: function(node, data) { data.otherNode.copyTo(node, data.hitMode); } }, glyph: glyph_opts, selectMode: 2, source: {url: "ajax-tree-taxonomy.json", debugDelay: 1000}, toggleEffect: { effect: "drop", options: {direction: "left"}, duration: 400 }, wide: { iconWidth: "1em", // Adjust this if @fancy-icon-width != "16px" iconSpacing: "0.5em", // Adjust this if @fancy-icon-spacing != "3px" levelOfs: "1.5em" // Adjust this if ul padding != "16px" }, icon: function(event, data){ // if( data.node.isFolder() ) { // return "glyphicon glyphicon-book"; // } }, lazyLoad: function(event, data) { data.result = {url: "ajax-sub2.json", debugDelay: 1000}; } });
source: {url: "ajax-tree-taxonomy.json", debugDelay: 1000}这行代码中调用的是同目录下的 ajax-tree-taxonomy.json文件,
但是我们浏览的时候会报错:ERROR 404.3 Not Found for JSON file
解决方法: Okay, the problem is that IIS has no JSON-File type by default (MIME) so you have to set it up: To set this for the entire server: 1. Open properties for your server in your IIS Manager and go for MIME Types. 2. Use "New" and enter "JSON" as extension and "application/json" for MIME.
这个的意思就是说我们需要设置IIS中的MIMI类型,新建JSON application/json类型即可
另外:浏览此类例子必须挂到IIS下,纯HTML不能读取文件