zoukankan      html  css  js  c++  java
  • 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不能读取文件

  • 相关阅读:
    JSTL和EL
    SpringMVC 上传文件and过滤器
    SQLServer 大数据查询2
    SQLServer 大数据查询分析
    Oracle分页查询
    Oracle大数据常见优化查询
    Window 下面利用Oid 获取SNMP主机信息 以及计算方法
    window 下面安装net-snmp 简单网关协议
    显示一行省略文字的详细信息
    手机自动隐藏浏览器地址栏
  • 原文地址:https://www.cnblogs.com/vevi/p/5421089.html
Copyright © 2011-2022 走看看