AngularJS实时搜索中的德语字符
我对MySQL的AngularJS实时搜索有问题,除德语字符外,一切都很完美。我尝试了一切但没有结果。
这是我的JS代码:
PATH = 'search.php';
var app = angular.module("myApp",[]);
//live search controller for welcome view and welcome controller
app.controller('SearchController', function($scope, $http){
$scope.url = 'search.php'; // the get request page
$scope.search = function (){
//create the http post request
//the data holds the search key
//the request is a json request
$http.post($scope.url,
{"data":$scope.keybords}
).success(function (data, status){
$scope.status = status;
$scope.data = data;
$scope.result = data;
}).error(function (data, status){
$scope.data = data || "Request Failed";
$scope.status = status;
});
};
});
这是我的PHP代码:
<?php
mysql_set_charset('utf8');
header('Content-Type: text/html; charset=utf-8');
require_once './db_connect.php';
$data = file_get_contents("php://input");
$objData = json_decode($data);
$key = $objData->data;
if(!empty($key)){
$sql = "SELECT * from search where title LIKE '%$key%' or description LIKE '%$key%' OR url LIKE '%$key%'";
$result = mysqli_query($link, $sql) or die(mysqli_error($link));
$output = array();
while ($row = mysqli_fetch_array($result)) {
$output[] = $row;
}
echo json_encode($output);
}
?>
...这里是testpage: http://www.topfertighaus.at/ng_live_search/index.html