相关疑难解决方法(0)

什么是Python的http.server(或SimpleHTTPServer)的更快的替代品?

Python的http.server(或Python的SimpleHTTPServer)是从命令行提供当前目录内容的好方法:

python -m http.server
Run Code Online (Sandbox Code Playgroud)

但是,就网络服务器而言,它非常低调......

它表现得好像是单线程的,并且在使用RequireJS加载JavaScript AMD模块时偶尔会导致超时错误.加载一个没有图像的简单页面可能需要五到十秒钟.

什么是更快的替代方案,同样方便?

command-line command-line-tool simplehttpserver httpserver

289
推荐指数
10
解决办法
12万
查看次数

使用javascript进行本地文件访问

是否有使用JavaScript完成的本地文件操作?我正在寻找一种可以在没有安装空间的情况下完成的解决方案,例如需要AIR.

具体来说,我想从文件中读取内容并将这些内容写入另一个文件.在这一点上,我并不担心获得权限,只是假设我已经拥有这些文件的完全权限.

javascript file-access

167
推荐指数
7
解决办法
33万
查看次数

使用d3.json导入本地json文件不起作用

我尝试使用导入本地.json文件d3.json().

该文件filename.json存储在与我的html文件相同的文件夹中.

然而(json)参数是空的.

d3.json("filename.json", function(json) {
    root = json;
    root.x0 = h / 2;
    root.y0 = 0;});
    . . . 
}
Run Code Online (Sandbox Code Playgroud)

我的代码与此d3.js示例中的代码基本相同

json d3.js

39
推荐指数
5
解决办法
6万
查看次数

尝试加载本地JSON文件以使用JQuery在html页面中显示数据

嗨,我试图使用JQuery加载本地JSON文件来显示数据,但我得到一些奇怪的错误.我可以知道如何解决这个问题.

<html>
 <head>
<script type="text/javascript" language="javascript" src="jquery-1.8.2.min.js"></script>        

<script type="text/javascript">
    $(document).ready(function(e) {
    $.getJSON( "priorities.json" , function( result ){
        alert(result.start.count);
    });
});
</script></head>
</html>
Run Code Online (Sandbox Code Playgroud)

我只是提醒JSON数据的数量.我的JSON文件位于此html文件所在的目录中,JSON字符串格式如下所示.

{
"start": {
    "count": "5",
    "title": "start",
    "priorities": [
        {
            "txt": "Work"
        },
        {
            "txt": "Time Sense"
        },
        {
            "txt": "Dicipline"
        },
        {
            "txt": "Confidence"
        },
        {
            "txt": "CrossFunctional"
        }
    ]
}
}
Run Code Online (Sandbox Code Playgroud)

JSON文件名的priority.json和错误是

未定义未捕获的Referenceerror优先级

html javascript jquery json

38
推荐指数
3
解决办法
26万
查看次数

为什么Angular在他们的教程中需要服务器?

查看快速入门分步教程,Angular需要一台服务器.

为什么Angular需要服务器?

我想专注于用户界面,并且让一台工作服务器一直让我失望 - 特别是在一个大型项目中,服务器一直不稳定,并且有大量未在本地配置的集成.

编辑[2015/08/12]:似乎服务器是必需的.尝试运行分步指南时,静态加载html(没有服务器)时不起作用.没有显示任何内容.该myapp标签只是没有得到界定的控制器.

angular

13
推荐指数
2
解决办法
4377
查看次数

使用 vanilla JS AJAX 请求访问本地 JSON 文件时出现 CORS 错误?

我正在尝试使用 vanilla JS AJAX 请求从本地存储的 JSON 文件中拉回 JSON 字符串(特别是尝试不使用 JQuery) - 以下代码基于 此答案-但我在 Chrome 控制台中不断收到错误消息(见下文)。任何想法我哪里出错了?我尝试更改 xhr.open 和 .send 请求的位置,但仍然收到错误消息。我怀疑问题出在 .send() 请求上?

//Vanilla JS AJAX request to get species from JSON file & populate Select box
function getJSON(path,callback) {

    var xhr = new XMLHttpRequest();                                         //Instantiate new request

    xhr.open('GET', path ,true);                                            //prepare asynch GET request
    xhr.send();                                                             //send request

    xhr.onreadystatechange = function(){                                    //everytime ready state changes (0-4), check it
        if (xhr.readyState === 4) {                                         //if request finished & response ready (4)
            if …
Run Code Online (Sandbox Code Playgroud)

javascript ajax json

5
推荐指数
1
解决办法
4967
查看次数

bootstrap模态数据远程无法在Chrome中运行

我有除了Chrome之外的所有浏览器的bootstrap模态数据远程工作.背景显示但不是模态本身.

parentPage.html

<a href="#" data-toggle="modal" data-target="#myModal"><img src="images/ball.gif" alt="Add Account"/></a>
<div class="modal fade" id="myModal" tabindex="-1" data-remote="./popups/remotePage.html" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false" >
</div>
Run Code Online (Sandbox Code Playgroud)

remotePage.html

<div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        Header
      </div>
      <div class="modal-body">
            One fine body...
      </div>
      <div class="modal-footer">Footer
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
Run Code Online (Sandbox Code Playgroud)

我已经尝试将数据远程放在<a>标签中.

我错过了什么?

html javascript css jquery twitter-bootstrap

4
推荐指数
1
解决办法
7507
查看次数

无法在Chrome中使用文件协议打开Angular应用

嗨,我有angularjs和chrome的问题,这是代码:

   var angularRoutingApp = angular.module('angularRoutingApp', ['ngRoute'])

   // Configuración de las rutas
   .config(function($routeProvider) 
   {

 $routeProvider
    .when('/', {
        templateUrl : 'pages/home.html',
        controller  : 'mainController'
    })
    .when('/artistas', {
        templateUrl : 'pages/artistas.html',
        controller  : 'artistasController'
    })
    .when('/login', {
        templateUrl : 'pages/login.html',
        controller  : 'loginController'
    })
    .otherwise({
        redirectTo: '/'
    });
    });
Run Code Online (Sandbox Code Playgroud)

如果我打开index.html与Opera,Firefox或safary我没有任何问题,但如果我打开这与Chorme不工作routerprovider并在控制台显示一个错误消息,如下所示:

XMLHttpRequest无法加载文件://localhost/Users/multivideo/Desktop/FTL-Angular/pages/home.html.仅支持HTTP的跨源请求.index.html的:1

Error: A network error occurred.
at Error (native)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.8/angular.min.js:72:206
at C (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.8/angular.min.js:68:99)
at f (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.8/angular.min.js:66:69)
at C (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.8/angular.min.js:92:375)
at C (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.8/angular.min.js:92:375)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.8/angular.min.js:94:28
at h.$eval (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.8/angular.min.js:102:293)
at h.$digest (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.8/angular.min.js:100:50)
at h.$apply …
Run Code Online (Sandbox Code Playgroud)

javascript google-chrome angularjs

4
推荐指数
1
解决办法
3904
查看次数