国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

When ajax requests data from the database in php and returns it to javascript using JSON, some data cannot be displayed. Can you please solve this problem?
過去多啦不再A夢(mèng)
過去多啦不再A夢(mèng) 2017-06-13 09:22:04
0
1
1040

What I write is a filtering function. I use ajax to request information from the database in php, and use JSON to pass it back to javascript. However, when entering relevant content, some filters can be read from the database, and some cannot. , I want to ask how to solve it.

javascript code:

submitElement.addEventListener('click',function(event){
     if(searchDescription === 1){
         search = filterByTitleElement.value;
     }else if(searchDescription === 2){
         search = filterByDescriptionElement.value;
     }

     //將輸入的搜索信息傳遞給php文件,讓其再數(shù)據(jù)庫中找到相應(yīng)的匹配項(xiàng)。

         var xmlhttp;
         if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
             xmlhttp = new XMLHttpRequest();
         }
         else {// code for IE6, IE5
             xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
         }
         xmlhttp.onreadystatechange = function () {
             if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                 a = eval('(' + xmlhttp.responseText + ')');
                                  tableDisplay.innerHTML = a.length;
                 }
             }
         };
         xmlhttp.open("GET", "SearchDeal.php?inputMessage=" + search + "&searchdescription=" + searchDescription, true);
         xmlhttp.send();
 });

 function pageForDisplay(number){
     var result = "<thead><tr><td>Search Result</td></tr></thead><tr><td><table border=\"1\" id=\"inside\">";
     for(var i = 0; i < 5 ;i++){
         result = result + " <tr><td><p class=\"photoInside\"><a href=\"DetailsPage.php\"><img src=\"travel-images/square-medium/" + a[number + i]['PATH'] +"\"></a>" +
             "<h3><a href=\"DetailsPage.php\">" + a[number + i]['Title'] +"</a></h3>" +
             "<p>" + a[number + i]['Description'] + "</p>" +
             "</p></td></tr>";
     }
      result = result + "</table></td></tr>";
     return result;

php code:

     $messageForSearch = $_GET["inputMessage"];
$messageForNumber = $_GET["searchdescription"];
$conn = mysqli_connect("localhost","root","","travel");
if($messageForNumber == 1){
    $sql = "SELECT ImageID,Title,Description ,PATH FROM travelimage where Title REGEXP '[$messageForSearch]'";
}else if($messageForNumber == 2){
   $sql = "SELECT ImageID,Title,Description ,PATH FROM travelimage where Description REGEXP '[$messageForSearch]'";
}
$a = mysqli_query($conn,$sql);
$json = mysqli_fetch_all($a,MYSQLI_ASSOC);
//print_r($json);
echo json_encode($json);
}

According to the above code, sometimes a.length will change, but sometimes it will not change (usually when there are too many filtered results). However, if I replace the last line of code in php with print_r($json), there will be output.

過去多啦不再A夢(mèng)
過去多啦不再A夢(mèng)

reply all(1)
僅有的幸福

json requires utf8 encoding, check whether the data obtained from the database is all utf8 encoded.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template