小编sia*_*one的帖子

只有HTTP支持跨源请求,但它不是跨域的

我正在使用此代码发出AJAX请求:

$("#userBarSignup").click(function(){
    $.get("C:/xampp/htdocs/webname/resources/templates/signup.php",
        {/*params*/},
        function(response){
            $("#signup").html("TEST");
            $("#signup").html(response);
        },
        "html");
Run Code Online (Sandbox Code Playgroud)

但是从Google Chrome JavaScript控制台我一直收到此错误:

XMLHttpRequest无法加载file:/// C:/xampp/htdocs/webname/resources/templates/signup.php.仅支持HTTP的跨源请求.

问题是signup.php文件托管在我的本地Web服务器上,这是所有网站运行的地方,因此它不是跨域的.

我怎么解决这个问题?

javascript

84
推荐指数
5
解决办法
29万
查看次数

找不到PHP类,但它已包含在内

我包含了一个PHP类

require_once($ENGINE."/classUser.php");
Run Code Online (Sandbox Code Playgroud)

但是当代码执行时,我收到此错误:

致命错误:第12行的C:\ xampp\htdocs\WebName\resources\engine\ajax\signup.php中找不到"用户"类

我仍然无法弄清楚问题是什么.我99%肯定这是正确的.

"$ ENGINE"是正确的,类也是正确的(Netbeans建议我使用类方法和变量).

signup.php:

<?php

/* Created on: 13/12/2011
 * Author: 
 * 
 * Description: User signup procedure.
 */

require_once("../settings.php");
require_once($ENGINE."/classUser.php");

$user = new User();
$user->createUser($_POST["username"], $_POST["email"], $_POST["password"]);


?>
Run Code Online (Sandbox Code Playgroud)

classUser.php:

<?php

/* Created on: 13/12/2011
 * Author: 
 * 
 * Description: This class manages users.
 */

require_once("settings.php");
require_once($LIBRARY."/cassandraphp/cassandra.php");

class User {

    public function createUser($username, $email, $password){
        $cassandra = Cassandra::createInstance($CASSANDRASERVER);
        $cassandra->set(
                "user.".$username,
                array(
                    'ID' => uniqid(),
                    'Username' => $username,
                    'Email' => $email,
                    'Password' => $password
                )
        );
    } …
Run Code Online (Sandbox Code Playgroud)

php

36
推荐指数
5
解决办法
9万
查看次数

Twitter Bootstrap隐藏了css类和jQuery

我正在使用hide css类来隐藏页面加载时的按钮.

问题是当我尝试显示按钮时,我已经预先用jQuery隐藏了按钮更小.

(当我使用jQuery隐藏然后显示按钮时,同样的事情不会发生)

谢谢你的帮助.

编辑:隐藏类就是这样:

.hide {
    display: none;
}
Run Code Online (Sandbox Code Playgroud)

我的按钮:

<a class="btn hide" id="buttonEditComment" href="javascript:void()"><i class="icon-comment"></i> Edit comment</a>
Run Code Online (Sandbox Code Playgroud)

我用javascript来显示按钮:

$("#buttonEditComment").toggle();
Run Code Online (Sandbox Code Playgroud)

jquery twitter-bootstrap

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

Cassandra是否适合存储文件?

我正在开发一个PHP平台,它将大量使用图像,文档和任何文件格式,这些都会在我脑海中浮现,所以我想知道Cassandra是否是我需要的好选择.

如果没有,你能告诉我应该如何存储文件吗?我想继续使用cassandra,因为它具有容错能力,并且在节点之间使用自动复制.

感谢帮助.

data-storage file-storage cassandra nosql

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

PHP - Laravel依赖注入:将参数传递给依赖构造函数

我正在构建一个Laravel项目,在一个控制器中,我在一个方法中注入了两个依赖项:

public function pusherAuth(Request $request, ChannelAuth $channelAuth) { ... }
Run Code Online (Sandbox Code Playgroud)

我的问题很简单:如何将参数传递给$channelAuth依赖项?

目前我正在使用一些setter传递所需的依赖项:

public function pusherAuth(Request $request, ChannelAuth $channelAuth)
{
    $channelAuth
        ->setChannel($request->input('channel'))
        ->setUser(Auth::user());
Run Code Online (Sandbox Code Playgroud)

这种方法有哪些替代方案?

PS代码需要是可测试的.

php dependency-injection

16
推荐指数
1
解决办法
8158
查看次数

Cassandra:备份整个密钥空间

我只是想知道在Cassandra中备份整个键空间的最佳方法是什么......你怎么看?

以前我只是将数据文件夹复制到我的备份硬盘中,但是在更新后我遇到了恢复数据库的问题.

backup cassandra

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

使用AJAX将HTML插入页面

我目前正在开发一个网站,我需要根据用户的操作动态加载页面.

示例:如果用户单击"设置"按钮,ajax函数将从外部页面加载代码,并将其放入带有"设置"标签的div中.

这是我用来发出Ajax请求的代码:

    function get_page_content(page, target_id)
    {
        xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function()
        {
            if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
            {
                document.getElementById(target_id).innerHTML = xmlhttp.responseText;
                // After getting the response we have to re-apply ui effects or they
                // won't be available on new elements coming from request.
                $('button').sb_animateButton();
                $('input').sb_animateInput();
            }
        }
        xmlhttp.open('GET', 'engine/ajax/get_page_content.php?page=' + page, true);
        xmlhttp.send();
    }
Run Code Online (Sandbox Code Playgroud)

这就是第一个片段将放置ajax结果的地方:

<div id="settings_appearance">                
</div>
Run Code Online (Sandbox Code Playgroud)

从这里的函数调用代码:

<div class="left_menu_item" id="left_menu_settings_appearance" onclick="show_settings_appearance()">
    Appearance
</div>
Run Code Online (Sandbox Code Playgroud)

这是ajax函数将放入settings_appearancediv 的html :

    <script type="text/javascript">
        $(function()
        { …
Run Code Online (Sandbox Code Playgroud)

html javascript xml ajax

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

在新创建的目录上设置了错误的权限

这是使用错误权限创建"cache"文件夹的代码:

mkdir($saveFolder, 02775);
Run Code Online (Sandbox Code Playgroud)

当我检查文件夹权限时,使用ls -la,我收到:

drwxr-sr-x
Run Code Online (Sandbox Code Playgroud)

但相反,我期待:

drwxrwsr-x
Run Code Online (Sandbox Code Playgroud)

php file-permissions

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

Nested dependencies and private repositories with composer

At the company I'm currently working we've recently started to move our code into different private repositories so that it's more maintainable and reusable (and also to make it easier to open-source it later).

Every PHP repository is also a Composer package that can be required in our project whenever we need it.

At the moment there's an issue with this approach: every time we need a package that depends on other packages we need to specify those also in …

composer-php

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

未捕获的SyntaxError:Browserify编译的文件中的无效或意外令牌

我的项目基于Laravel并使用Laravel Elixir来编译和缩小客户端代码(用ECMAScript 6编写).

我注意到如果我对客户端代码进行任何更改,然后使用gulp并重新加载页面再次编译所有内容我在Chrome中收到以下错误:

未捕获的SyntaxError:无效或意外的令牌

无法解析SourceMap:http://192.168.99.100/js/app.js.map

如果我检查,app.js我可以看到为什么我遇到这个问题:

在此输入图像描述

每个红点都是角色\u0.

之后我在IDE中检查了同一个文件,最后没有这样的字符.

如果我还原我的更改,然后再次重新编译,gulp一切都开始工作.

我的gulpfile.js:

var elixir = require('laravel-elixir');
require('laravel-elixir-vueify');

// Enable full sourcemaps with browserify. Disable in production.
elixir.config.js.browserify.options.debug = true;

// Disable notifications
process.env.DISABLE_NOTIFIER = true;

elixir(function(mix)
{
    // Compile SASS
    mix.sass('app.scss');

    mix.browserify('app.js');

    mix.browserSync({
        notify : false,
        open: false,        
        proxy : '192.168.99.100',
        reloadDelay: 2000
    });
});
Run Code Online (Sandbox Code Playgroud)

不确定是否重要,但应用程序在由Mac OS X托管的共享文件夹内的多个docker容器中运行.

laravel browserify laravel-elixir

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