小编Man*_*roi的帖子

从 php 文件中获取 api(获取数据)

我正在尝试从 php 文件中获取值

api.php

      <?php
      // want to fetch this value 
      $a = 'come!! fetch this value';

      ?>
Run Code Online (Sandbox Code Playgroud)

我的javascript页面有这样的代码。(此代码不在页面api.php上)

            fetch('http://localhost/react_task/react-webpack-boilerplate/php/api.php', {
        method: 'get',
        // may be some code of fetching comes here
    }).then(function(response) {
            if (response.status >= 200 && response.status < 300) {
                return response.text()
            }
            throw new Error(response.statusText)
        })
        .then(function(response) {
            console.log(response);
        })
Run Code Online (Sandbox Code Playgroud)

你能指导我如何使用 fetch 从 php 文件中获取变量的值吗?

javascript php get fetch-api

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

firebase:“无法解析身份验证令牌。”

您好,我正在将Firebase与php一起使用并使用此

我收到此错误。“无法解析身份验证令牌。”

我的身份验证令牌是正确的,因为我也已将相同的令牌与node.js一起使用。

我的代码看起来像这样

       require "vendor/autoload.php";
       const DEFAULT_URL = 'https://xxxxxxxxx.firebaseio.com';
       const DEFAULT_TOKEN = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';

       $firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN );  

        $data = [
        "Website_Name"=> $Website_Name,
        "Username" =>  $Username,
       "Password"=> $Password,
       "website_link"=> $website_link,
       "id"=> $id,
       ];



        $path = "per_users";
        $res = $firebase->push('/per_users', $data);
        // per_users is the name of the table
        var_dump($res); 
Run Code Online (Sandbox Code Playgroud)

你能告诉我我到底在做什么错。谢谢。

php firebase firebase-authentication

4
推荐指数
2
解决办法
4029
查看次数

在React.js中检索checkbox的值

我想在选中复选框时检索其复选框的值.

我正在使用这个" http://react-component.github.io/checkbox/ ".

我的代码看起来像这样.

<div className="user_box">
    { check.map((values , i)=> {
        return <Checkbox
            name = "checkbox"
            onChange={this.checkvalue.bind(this)}
            value={values.username} 
        />
    })}
</div>
Run Code Online (Sandbox Code Playgroud)

我的功能:

checkvalue(e){
    // var all_users = [];
    // var value = this.checkbox.value;
    // all_users.push(value);
    // console.log(all_users);

    console.log('checkbox checked:', (e.target.checked));
}
Run Code Online (Sandbox Code Playgroud)

我不明白如何检索复选框的值.

javascript checkbox reactjs

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