Javascript 为什么我在执行';console.log()和#x27;在'$http';安格拉斯
这里我使用codeigniter和AngularJS。。。。 我的代码怎么了 我想,我想从“输入文本”中检索它的数据 我只在执行“console.log()时获取空数据” 在index.html中Javascript 为什么我在执行';console.log()和#x27;在'$http';安格拉斯,javascript,php,angularjs,codeigniter,Javascript,Php,Angularjs,Codeigniter,这里我使用codeigniter和AngularJS。。。。 我的代码怎么了 我想,我想从“输入文本”中检索它的数据 我只在执行“console.log()时获取空数据” 在index.html中 <input type="text" ng-model="search_data"> <span class="display-ib" ng-click="testGetDataSearch()"></span> 在AjaxRequest.php中 public
<input type="text" ng-model="search_data">
<span class="display-ib" ng-click="testGetDataSearch()"></span>
在AjaxRequest.php中
public function naonwelah()
{
if ( isset($_GET['valSearch'])) {
$searchValue = $_GET['valSearch'];
$result = $this->dbxs7h3j9213m02147ca_model->cariBrow($searchValue);
var_dump($result);
}
}
如果直接打开搜索url会发生什么?你有输出吗?您是否检查了ChromeDevTools中的请求?这也可能有助于缩小问题的范围
然而,一个问题可能是var_dump不会生成有效的JSON。非常简单,将“data:”更改为“params:”,然后尝试以下操作:)
谢谢您的评论,但是当我在jQuery上使用$.ajax()时,我得到了我认为合适的结果
public function naonwelah()
{
if ( isset($_GET['valSearch'])) {
$searchValue = $_GET['valSearch'];
$result = $this->dbxs7h3j9213m02147ca_model->cariBrow($searchValue);
var_dump($result);
}
}
$scope.testGetDataSearch = function()
{
$http({
method: 'GET',
url: 'home/naonwelah',
params: { 'valSearch': $scope.search_data }
}).then(function (data){
console.log(data);
},function (error){
console.log(error);
});
}