无法在XML和JSON输出页面上单击锚标签

时间:2015-01-11 18:32:12

标签: php html xml json

可能是一个简单的解决办法,但过去几个小时我就有了。

基本上,在我的网站上我有一个导航栏。这些都包含在'nav.php'中。我在两个单独的页面上输出JSON和XML。在这些页面上,无法单击导航栏。好像整个页面冻结了。它在网站的其他部分工作正常。

JSON页面

<?php
require_once __DIR__ . ('/../config/init.php');

    $mysqli = new mysqli($db['hostname'], $db['username'], $db['password'], $db['database']);
        if ($mysqli->connect_errno) {
            printf("Connect failed: %s\n", $mysqli->connect_error);
            exit();
        }

        $sql = "SELECT * FROM news WHERE live = '1'";
        $result = mysqli_query($mysqli,$sql);
        $json = array();


        while($row=mysqli_fetch_row($result)){
            $json['news'][]=$row;
          }
         ?>

<!DOCTYPE html>
<html>
<head>
    <?php
        include INCLUDES . 'head_tags.php';
    ?>
</head>
<body>
    <div class='container'>
    <?php
        include INCLUDES . 'header.php';
        include INCLUDES . 'nav.php';
    ?>
        <div class='two-thirds column'>
            <div class='json'>
            <?php
            echo json_encode($json);
            ?>
            </div>
        </div>


    <?php
        include INCLUDES . 'footer.php';
    ?>
    </div>
</body>
</html>

XML页面

<?php

$xml = new DOMDocument;
$xml->load('http:/mysite.co.uk/index_xml.php');

$xsl = new DOMDocument;
$xsl -> load('style.xsl');

$proc = new XSLTProcessor;

$proc -> importStyleSheet($xsl);



?>

<?php
    //Require config file outside of head tags so functions and classes can be used before html is loaded
    require_once __DIR__ . ('/config/init.php');
?>
<!DOCTYPE html>
<html>
<head>
    <?php
        //Only has tags that go instead the <head> tag 
        include INCLUDES . 'head_tags.php';
    ?>
</head>
<body>
    <div class='container'>
    <?php
        include INCLUDES . 'header.php';
        include INCLUDES . 'nav.php';
    ?>
        <div class='two-thirds column'>
            <?php
            echo $proc -> transformToXML($xml);
            ?>
        </div>


    <?php
        include INCLUDES . 'footer.php';
    ?>
    </div>
</body>
</html>

干杯!

0 个答案:

没有答案