Php 如何使用AJAXPOST在ionic中实现此搜索查询?
我的codeigniter中有这个搜索查询,问题是我不知道如何在ionic中实现它。我想要的是,如果我在我的ionic(home.html)比如“胡椒,油”的搜索框中搜索,结果应该是与adobo和kaldereta等成分对应的配方 user_model.php(codeigniter-model) php(codeigniter-controller) searchService.js(离子型) controller.js(离子型) home.html(爱奥尼亚-视图)Php 如何使用AJAXPOST在ionic中实现此搜索查询?,php,mysql,ajax,codeigniter,ionic-framework,Php,Mysql,Ajax,Codeigniter,Ionic Framework,我的codeigniter中有这个搜索查询,问题是我不知道如何在ionic中实现它。我想要的是,如果我在我的ionic(home.html)比如“胡椒,油”的搜索框中搜索,结果应该是与adobo和kaldereta等成分对应的配方 user_model.php(codeigniter-model) php(codeigniter-controller) searchService.js(离子型) controller.js(离子型) home.html(爱奥尼亚-视图) 搜寻 使用paylo
搜寻
使用payload.data获取响应
使用payload.data获取响应。当您调用ajaxSearchHalal()时,您会得到什么?有错误吗?我把所有的菜谱都放在类别_id=1下。帕雷什加米先生,这种情况似乎不起作用。当你调用ajaxSearchHalal()时,我编辑并在上面放了一个屏幕盖。你得到了什么?有错误吗?我把所有的菜谱都放在类别_id=1下。帕雷什加米先生,这种情况似乎不起作用。我编辑并在上面放了一个屏幕盖
public function get_halal($search_values)
{
$this->db->distinct();
$this->db->select('*');
$this->db->from('recipe');
$this->db->join('menu', 'menu.recipe_id = recipe.recipe_id');
$this->db->join('ingredient', 'ingredient.ingredient_id = menu.ingredient_id');
$this->db->where('menu.category_id = 1');
if (strpos($search_values, ',') !== false) {
$search = explode(',' , $search_values);
$this->db->like('ingredient.name', trim($search[0]), 'both');
unset($search[0]);
foreach ($search as $term) {
$this->db->or_like('ingredient.name', trim($term), 'both');
}
} else {
//this means you only have one value
$this->db->like('ingredient.name',$search_values, 'both');
}
$query = $this->db->get();
return $query->result();
}
public function ajaxSearchHalal()
{
$postdata = file_get_contents("php://input");
if (isset($postdata)) {
$data = $this->user_model->get_halal($postdata);
echo json_encode($data);
}
}
return {
all: function() {
return $http.get('http://localhost/admin-recipick/home/ajaxSearchHalal').then(function(result){
return result.data;
console.log(result.data);
});
}
}
RecipeList.all().then(function(payload) {
$scope.recipedata = payload;
console.log(payload);
});
$scope.searcRecipe = function() {
RecipeList.all();
$state.go('app.searchRecipe');
};
<div class="list list-inset">
<label class="item item-input">
<i class="icon ion-search placeholder-icon"></i>
<input type="text" ng-model="" placeholder="(EX. beef, fish, corn)">
</label>
<button type="button" class="button button-block button-assertive icon ion-search " ng-Click="searcRecipe()"> Search</button>
</div>
RecipeList.all().then(function(payload)
{
console.log(payload.data);
});