php ci ajax用户登录,使用jQuery和CI显示AJAX调用数据库的数据
模型似乎和控制器一樣工作。 AJAX將結果顯示為“null”,所以我認為這是因為我們需要將數據作為json發送。如何將數據放到正確的格式,并在視圖中顯示任何想法使用jQuery和CI顯示AJAX調用數據庫的數據
查看
Get Data.
hola amigo
$('#getdata').click(function(){
$.ajax({
url: '<?php echo base_url().'index.php/trial/getValues';?>',
type:'POST',
dataType: 'json',
error: function(){
$('#result_table').append('
goodbye world
');},
success: function(results){
$('#result_table').append('
hello world
');} // End of success function of ajax form
}); // End of ajax call
});
控制器
function getValues(){
$this->load->model('get_db');
$data['results'] = $this->get_db->getAll();
return $data;
}
型號
class Get_db extends CI_Model{
function getAll(){
$query=$this->db->query("SELECT * FROM questions");
return $query->result();
//returns from this string in the db, converts it into an array
}
}
總結
以上是生活随笔為你收集整理的php ci ajax用户登录,使用jQuery和CI显示AJAX调用数据库的数据的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PHP多选题怎么弄,php多选题评分算法
- 下一篇: PHP redis秒杀返回结果,php结