相关疑难解决方法(0)

"只有HTTP支持跨源请求." 加载本地文件时出错

我正在尝试将3D模型加载到Three.js中JSONLoader,并且该3D模型与整个网站位于同一目录中.

我收到了"Cross origin requests are only supported for HTTP."错误,但我不知道是什么导致它,也不知道如何解决它.

javascript 3d http file three.js

758
推荐指数
14
解决办法
110万
查看次数

加载URL svg的不安全尝试

我在Chrome中尝试在本地文件系统上加载SVG时遇到错误:

不安全的尝试从URL文件加载URL文件:/// C:/Users/Me/Documents/HTML/icons.svg#menu:/// C:/Users/Me/Documents/HTML/master.html.域,协议和端口必须匹配.

这是我的HTML:

<svg id="icon-menu" viewBox="0 0 70 60">
   <use xlink:href="icons.svg#menu"></use>
</svg>
Run Code Online (Sandbox Code Playgroud)

和SVG:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   viewBox="0 0 70 70">
  <g
     id="menu">
    <path
       d="m 10,15 50,0"
       style="fill:none;stroke:#ffffff;stroke-width:4;stroke-linecap:round;" />
    <path
       d="m 10,30 50,0"
       style="fill:none;stroke:#ffffff;stroke-width:4;stroke-linecap:round;" />
    <path
       d="m 10,45 50,0"
       style="fill:none;stroke:#ffffff;stroke-width:4;stroke-linecap:round;" />
  </g>
</svg>
Run Code Online (Sandbox Code Playgroud)

我在互联网上搜索过,但我能找到的唯一解决方案是用JavaScript编写的代码,但事实并非如此.上面的HTML在IE中不起作用,没有错误,但在Firefox中没有任何障碍.

html svg google-chrome

19
推荐指数
1
解决办法
3万
查看次数

仅支持HTTP的跨源请求

我正在尝试运行此代码:

<!DOCTYPE html>
<html ng-app="myApp">
<head>
    <title>Exemple 06</title>
</head>
<body>
    <!-- Diretiva ng-repeat -->
    <div ng-controller="MyController">
        <a ng-href="#/">Page 1</a> | <a ng-href="#/p2">Page 2</a>
        <div ng-view="#/p2"></div>
    </div>

    <script src="js/angular.js"></script>
    <script src="js/angular-route.js"></script>
    <script type="text/javascript">
        var myApp = angular.module('myApp', ['ngRoute']);

        myApp.config(function($routeProvider){
            $routeProvider
                .when('/'  , {controller: 'MyController', templateUrl: 'p1.html'})
                .when('/p2', {controller: 'MyController', templateUrl: 'p2.html'})
                .otherwise({ redirectTo: '/'});
        });

        myApp.controller('MyController', function($scope){
            $scope.nomes = [
                {id: 1, nome: 'Arthur'},
                {id: 2, nome: 'Portos'},
                {id: 3, nome: 'Aramis'}
            ];
        });
    </script>
</body>
Run Code Online (Sandbox Code Playgroud)

但是会出现以下错误:

XMLHttpRequest无法加载file:///home/93579551515/Desktop/Angular/p1.html.仅支持HTTP的跨源请求.

我不想在网络服务器上运行它.

angularjs angularjs-routing

10
推荐指数
1
解决办法
3万
查看次数

尝试停用Chrome同源策略

我正在尝试遵循melonJS教程.它说我应该使用以下两种方法之一禁用跨源请求:

- 禁用网络安全

--allow-文件访问从档案**

我在命令提示符中尝试了这两个:

C:\Users\danniu>C:\Users\danniu\AppData\Local\Google\Chrome\Application\Chrome.e
xe --allow-file-access-from-files

C:\Users\danniu>C:\Users\danniu\AppData\Local\Google\Chrome\Application\Chrome.e
xe --disable-web-security
Run Code Online (Sandbox Code Playgroud)

当我尝试在Chrome中运行游戏时,我仍然收到此错误:

XMLHttpRequest cannot load file:///C:/Users/danniu/Desktop/JavaScript/melonJS/data/map/area01.tmx. Cross origin requests are only supported for HTTP.

我究竟做错了什么?

谢谢

javascript security google-chrome same-origin-policy

8
推荐指数
1
解决办法
6万
查看次数

使用ggplot2中的圆形包装可视化分层数据?

我有一些分层数据,例如,

> library(dplyr)
> df <- data_frame(id = 1:6, parent_id = c(NA, 1, 1, 2, 2, 5))
> df
Source: local data frame [6 x 2]

     id parent_id
  (int)     (dbl)
1     1        NA
2     2         1
3     3         1
4     4         2
5     5         2
6     6         5
Run Code Online (Sandbox Code Playgroud)

我想通过圆形包装图在"自上而下"的视图中绘制树:http: //bl.ocks.org/mbostock/4063530

圆形包装图

以上链接适用于d3库.是否有一个等价物允许我在ggplot2中制作这样的情节?

(我希望这个情节在一个闪亮的应用程序,它确实支持d3,但我之前没有使用过d3并且不确定学习曲线.如果d3是明显的选择,我会尝试让它工作.谢谢.)

r treemap ggplot2

6
推荐指数
1
解决办法
2924
查看次数

Angularjs ng-view不显示数据

我正在通过AngularJS教程从Tuts + Easier JavaScript应用程序学习Angularjs.现在,我正处于使用ng-view讨论Routing Primer的部分.我试图在索引页的ng-view中显示列表页面内容.出于某种原因,当我加载index.html时没有显示任何内容.我从搜索中发现,从角度1.2.0开始,ngRoute已被移动到自己的模块中.我必须单独加载它并声明依赖项.但我仍然无法在列表页面显示任何内容.

的index.html

<!doctype html>
<html ng-app="myApp">
  <head>
  <title>Angular App</title>
    <script src="js/angular.min.js"></script>
    <script src="js/angular-route.min.js"></script>
    <script src="app.js"></script>
  </head>
  <body>
    <div ng-controller="Ctrl">
      <div ng-view></div>
    </div>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

list.html

<h3>List</h3>
<ul>
    <li ng-repeat="contact in contacts">
      <a href="#">{{contact.name}}</a>: {{contact.number}}
    </li>
</ul>
Run Code Online (Sandbox Code Playgroud)

app.js

    var app = angular.module('myApp', ['ngRoute']);

    app.config(function($routeProvider) {
        $routeProvider.when('/', {
            templateUrl: 'list.html',
            controller: 'Ctrl'
        });
    });

    app.controller('Ctrl', function($scope){
        $scope.contacts = [
            { name: 'Shuvro', number: '1234' },
            { name: 'Ashif', number: '4321' },
            { name: 'Anik', number: '2314' }
        ]; …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs

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

XMLHttpRequest; 跨源请求仅支持以下协议方案:http、data、chrome、chrome-extension、https、chrome-extension-resource

当我尝试进行 ajax 调用时,我在下面的 chrome 上遇到了错误。

XMLHttpRequest 无法加载 javascript:;。跨源请求仅支持以下协议方案:http、data、chrome、chrome-extension、https、chrome-extension-resource。

这是代码:

$.ajax({
    type: "POST",
    data: {pvalue : pid},
    cache: false,
    url: "xxx.in/yy/ajax.php",
    success: function(data)
    {
      $modal.find('.edit-content').html(data);
    }
Run Code Online (Sandbox Code Playgroud)

javascript php ajax jquery google-chrome

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