小编tax*_*ala的帖子

在Htdocs之外创建XAMPP/Apache服务文件

是否可以配置xampp来提供htdocs目录之外的文件?

例如,假设我有一个文件如下:

C:\projects\transitCalculator\trunk\TransitCalculator.php

我的xampp文件通常来自:

C:\xampp\htdocs\

(因为那是默认配置)有没有办法让Apache识别并提供我的TransitCalculator.php文件而不移动它htdocs?我希望Apache能够提供/访问项目目录的全部内容,而且我不想移动项目目录htdocs.

编辑:编辑将Apache添加到问题标题,使Q/A更"可搜索"

php apache xampp server-configuration

295
推荐指数
6
解决办法
24万
查看次数

确定ajax调用是否因不安全的响应或连接被拒绝而失败

我一直在做很多研究,但找不到办法解决这个问题.我正在尝试从https服务器执行jQuery ajax调用到运行带有自定义自签名证书的jetty的locahost https服务器.我的问题是我无法确定响应是拒绝连接还是不安全响应(由于缺少证书接受).有没有办法确定两种情景之间的差异?的responseText,并且statusCode总是在这两种情况下是相同的,即使在Chrome控制台我可以看到一个区别:

net::ERR_INSECURE_RESPONSE
net::ERR_CONNECTION_REFUSED
Run Code Online (Sandbox Code Playgroud)

responseText总是""并且statusCode对于两种情况总是"0".

我的问题是,如何确定jQuery ajax调用是否因为ERR_INSECURE_RESPONSE或由于ERR_CONNECTION_REFUSED?而失败?

一旦证书被接受,一切正常,但我想知道本地主机服务器是关闭,还是启动并运行,但证书尚未被接受.

$.ajax({
    type: 'GET',
    url: "https://localhost/custom/server/",
    dataType: "json",
    async: true,
    success: function (response) {
        //do something
    },
    error: function (xhr, textStatus, errorThrown) {
        console.log(xhr, textStatus, errorThrown); //always the same for refused and insecure responses.
    }
});
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

即使手动执行请求,我也会得到相同的结果:

var request = new XMLHttpRequest();
request.open('GET', "https://localhost/custom/server/", true);
request.onload = function () {
    console.log(request.responseText);
};
request.onerror = function () {
    console.log(request.responseText);
};
request.send();
Run Code Online (Sandbox Code Playgroud)

javascript ajax https jquery cors

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

Pagespeed Javascript缩小/连接 - 添加横幅和页脚

我有一个使用Pagespeed与NGINX一起运行的网站,以便缩小和连接Javascript资源,我需要的(如果可能的话,使用Pagespeed)是为缩小的结果添加横幅和页脚,例如Grunt:

Grunt文件配置代码段:

concat: {
    scripts: {
        options: {
            banner: "(function(){",
            footer: "}());"
        },
        src: ['src/app/app.module.js', 'src/app/components/**/*.js', 'src/app/shared/**/*.js'],
        dest: 'dist/scripts/app.min.js'
    },
    vendor: {
        src: ['src/assets/js/vendor/**/*.js'],
        dest: 'dist/scripts/vendor.min.js'
    }
},
Run Code Online (Sandbox Code Playgroud)

这可以通过Pagespeed实现吗?我想在同一个私有范围中添加缩小的所有内容:(function(){ //...minified code...}());

我一直在阅读文档,但找不到与此主题相关的任何内容.

concat nginx minify pagespeed mod-pagespeed

11
推荐指数
1
解决办法
409
查看次数

Php/OOP如何避免同一类的实例从其他对象访问私有属性/方法

我知道大多数OOP语言(如果不是全部)的私有可见性在类的基础上定义隐私,即同一类的不同实例可以访问彼此的私有属性/方法.

我想阻止这一点,我想知道什么是最好的设计/实现,以便在不产生负面性能影响的情况下做到这一点.

例如,我知道我可以实现AOP并使用符号,但这会导致性能下降,因为languange引擎必须创建类的反射并检查注释.所以,基本上,我的问题是,避免同一个类的实例访问彼此的私有方法/属性的最佳方法是什么?

例:

class Product
{
    private $_prize;
    public function __construct($prize)
    {
        $this->_prize = $prize;
    }

    public function calculateDiscount(Product $extraProduct)
    {
        $extraProduct->_prize = 0; //How to avoid this?
    }
}

$productA = new Product(10);
$productB = new Product(25);
$productA->calculateDiscount($productB);
Run Code Online (Sandbox Code Playgroud)

php oop

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

TypeError:$ timeout不是函数

这里发生了什么:

我希望"取消预订"按钮在点击后有一个超时.首次点击它会更改为显示"确认取消"按钮.几秒钟后,它返回"取消预订".

我的控制台给了我:

TypeError: $timeout is not a function
Run Code Online (Sandbox Code Playgroud)

我正在使用AngularJS $ timeout:

控制器:

'use strict';

module.controller('ReservationItemCtrl', ['$scope', '$stateParams', '$RPC',
    function($scope, $stateParams, $RPC, $timeout) {


 ......other stuff.......
 ......other stuff.......

    $scope.toggleCancelReservation = function(reservation) {
        reservation.clickedcancel = true;
        $timeout(function(){reservation.clickedcancel = false}, 4000);
    };
}
]);
Run Code Online (Sandbox Code Playgroud)

模板:

  <button ng-show="!reservation.value.deleted && !deleted.value"
          class="btn btn-danger" 
          ng-show="canCancel(reservation)" ng-if="!reservation.clickedcancel" ng-click="toggleCancelReservation(reservation)">
    Cancel With Refund
  </button>
  <button type="button" class="btn btn-danger" ng-if="reservation.clickedcancel == true" ng-click="deleteReservation();" style="margin-top: -4px;">
    Confirm Cancellation
  </button>
Run Code Online (Sandbox Code Playgroud)

我准确地在第一次点击时切换按钮然后再次点击它会正确取消/删除预订,但如果我在第一次点击后没有做任何事情,那么超时永远不会将其返回到原始按钮.在我的控制台中,$timeout is not a function由于某种原因我看到了吗?我把它包含在我的控制器中.我错过了什么吗?

javascript timeout settimeout angularjs angularjs-directive

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

"自我"关键字在WebWorkers中意味着什么

我不明白7,8,9行:

var worker = new Worker('doWork.js');

worker.addEventListener('message', function(e) {
  console.log('Worker said: ', e.data);   // Here it send's the data.
}, false);

worker.postMessage('Hello World'); // Send data to our worker.



 //7 self.addEventListener('message', function(e) {
   //8   self.postMessage(e.data);
   //9 }, false);
Run Code Online (Sandbox Code Playgroud)

做这段代码的是什么?1.什么代码行在第7行触发消息事件?2.在第8行的postMessage中传递了什么数据?3.自我做什么?

javascript self web-worker

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

断开D3每个循环没有标志

请考虑以下代码:

circle.each(function (d) {
    //...code
});
Run Code Online (Sandbox Code Playgroud)

我该如何打破循环?是否有一种自然的D3方式来突破每个循环?我的意思是没有国旗如下:

var flag = false;
circle.each(function (d) {
    if (flag) return;
    if (someCondition) flag = true;
    //...code
});
Run Code Online (Sandbox Code Playgroud)

我已经尝试在if语句中返回false但是它没有用(想想也许这会起作用,jquery.each但我错了):

circle.each(function (d) {
    if (someCondition) return false; //Not working
    //...code
});
Run Code Online (Sandbox Code Playgroud)

javascript each d3.js

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

在json中解码html

我在 json 中有 html,它已经被编码(通过 c#)到:

{"itemID":6,"GlossaryWord":"ante","GlossaryDescription":"\u003cp\u003e\r\n\t\u003cstrong\u003eUp the ante\u0026nbsp;\u003c/strong\u003e\u003c/p\u003e\r\n\u003cul\u003e\r\n\t\u003cli\u003e\r\n\t\t\u003cstrong\u003eHere\u003c/strong\u003e\u003c/li\u003e\r\n\t\u003cli\u003e\r\n\t\t\u003cstrong\u003eis\u0026nbsp;\u003c/strong\u003e\u003c/li\u003e\r\n\t\u003cli\u003e\r\n\t\t\u003cb\u003esomething\u003c/b\u003e\u003c/li\u003e\r\n\u003c/ul\u003e\r\n","CategoryID":6}
Run Code Online (Sandbox Code Playgroud)

But how would I decode GlossaryDescription in JavaScript/AngularJS so that it displays the html tags like <p> & <strong> etc? Thanks as always :)

html javascript c# json angularjs

2
推荐指数
1
解决办法
9079
查看次数

如何访问对象数据php cakephp 3.1

这是一个cakephp 3.1查询结果,我想直接访问$ data-> items但是我得到一个错误,说找不到关键项,我不想使用funtcion toArray(),因为如果我这样做的话将仅返回'items'=> ...并且我丢失了所有'query'=> ...信息.你能用正确的语法来帮助我获得$ data-> items或$ data - > {'items'} ....

$data = object(Cake\ORM\ResultSet) {

    'query' => object(Cake\ORM\Query) {

        '(help)' => 'This is a Query object, to get the results execute or iterate it.',
        'sql' => 'SELECT Posts_types.id AS `Posts_types__id`, Posts_types.name AS `Posts_types__name` FROM posts_types Posts_types ORDER BY id ASC',
        'params' => [],
        'defaultTypes' => [
            'Posts_types.id' => 'integer',
            'id' => 'integer',
            'Posts_types.name' => 'string',
            'name' => 'string'
        ],
        'decorators' => (int) 0,
        'executed' => true,
        'hydrate' …
Run Code Online (Sandbox Code Playgroud)

php cakephp

2
推荐指数
1
解决办法
5273
查看次数