0
私はエラーを取得[表示] -後JSONは
<?php
$url = site_url('user/category/showCategoryJson'); // path to your JSON file
$data = file_get_contents($url); // put the contents of the file into a variable
$results = json_decode($data,true); // decode the JSON feed
foreach ($results[0] as $key => $cat) {
?>
<tr class="odd gradeX">
<td><?php echo $cat['categoryname']; ?></td>
<td><?php echo $cat['username']; ?></td>
<td class="center"><a class="btn btn-success fa fa-edit editcat" id="<?php echo $cat['categoryid']; ?>" data-toggle="modal" data-target="#modal<?php echo $cat['categoryid']; ?>"></a> <a class="btn btn-danger fa fa-trash delete" id="<?php echo $cat['categoryid']; ?>"></a></td>
</tr>
<?php } ?>
で、その後コード -
public function __construct(){
parent::__construct();
if(!isset($_SESSION['login'])){
redirect('welcome');
}
}
のこの作品を使用するときに私のコードは、うまく動作していたが。動作していない、ログインせずに直接リンクへのアクセスを防ぎますしかし、コンストラクタ内のコードを無視しても、すべてが完全に機能しています。私は何をすべきか教えてください。ここ
Iが表示 -
public function showCategoryJson(){
$this->load->model('user/category_model');
$data[] = $this->category_model->displayCategory();
echo json_encode($data);
}
に同じコントローラで両方コンストラクタとshowCategoryJson()関数を呼び出してい関数です。ここで
は、あなたがあなた自身のサーバーからJSONを取得するためにHTTPのURLを構築しているエラー -
迅速な回答ありがとうございます。はい、私はこの問題を投稿する前に、私はすでにこの手法を適用しています。つまり、方法はありませんか? :( – user3311692
PHPを書いて、サーバにログインできるようにすることができます(あなたのログインシステムの仕方によって異なります)。同じサーバであると仮定すると、非常に複雑で非効率です。 – Quentin