0

我正在尝试使用 phonegap 构建 Android 应用程序。

我正面临这个问题,当我从数据库中获取数据时,所有数据都没有被检索到,只显示了几个单词,其余数据没有显示。我想获得 800 个单词的数据,但它只显示 80 个单词。我不知道是什么问题。

这是我的phonegap 的index.html 文件。

$(document).on('click', '#bio', function(e) {

                        var xmlhttp = new XMLHttpRequest();
            var url = "http://example/api/about.php";

            xmlhttp.onreadystatechange=function() {
                if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                    myFunction(xmlhttp.responseText);
                }
            }
            xmlhttp.open("GET", url, true);
            xmlhttp.send();

            function myFunction(response) {
                var arr = JSON.parse(response);
                var i;
                var eventinfo = '';
                for(i = 0; i < arr.length; i++) {

                  console.log(arr[i]);
                  eventinfo += '<li data-role="list-divider" role="heading" class="ui-li ui-li-divider ui-bar-b ui-li-has-count ui-first-child"><span class="ui-li-count ui-btn-up-c ui-btn-corner-all">2</span></li>';
                  eventinfo += '<li data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-icon="arrow-r" data-iconpos="right" data-theme="c" class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-btn-up-c">';
                 eventinfo += ' <div data-role="collapsible" data-theme="c" data-content-theme="d"><h2 class="ui-li-heading">'+ arr[i].Title +'</h2> </div>';


                }

                document.getElementById("biographyView").innerHTML = eventinfo;
            }

          });
 <div data-role='page' id='biography'>
        <div data-role="header" data-theme="b">
          <h1>BJP Punjab</h1>
          <a href="#left-panel" data-theme="d" data-icon="arrow-r" data-iconpos="notext" data-shadow="false" data-iconshadow="false" class="ui-icon-nodisc">Home</a>

        </div> <!-- /header -->
        <div data-role="content">
          <div class="bar bar-header bar-positive" style="margin-bottom:80px;">

           <h1 class="title">Biography Of Shri Vijay sampla ji</h1>
           </div>
           <ul data-role="listview" class="list ui-listview ui-listview-inset ui-corner-all ui-shadow" id="biographyView" data-inset="true">

           </ul>

        </div>
      </div>

这是我的 php 文件

<?php
 //require ("../wp-load.php");
 //include("conn.php");
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
 $servername = "localhost";
 $username = "root";
 $password = "....myDbPassword...";
 $dbname = "example";
 // Create connection
 $conn = new mysqli($servername, $username, $password, $dbname);
 // Check connection
 if ($conn->connect_error) 
     {
   die("Connection failed: " . $conn->connect_error);
     } 

        $result = $conn->query("SELECT post_content FROM `wp_posts`WHERE post_title = 'About Us' && post_status='publish'"); 

$outp = "[";
while($rs = $result->fetch_array(MYSQLI_ASSOC)) {
    if ($outp != "[") {$outp .= ",";}
         $outp .= '{"Title":"' . $rs["post_content"] . '"}';

   }
$outp .="]";

    $conn->close();

$after  = json_encode(json_decode($outp));
echo($outp);

?>
4

0 回答 0