|
本帖最后由 新手学习 于 2013-10-3 23:53 编辑
在做一个 局部刷新读取数据库的功能!用的是
jQuery ajax - ajax() 方法
-------------------这是View页面---------------------
HTML复制代码
<div id="div1"> </div>
<p id='demo'></p>
</div>
<script type="text/javascript">
var test = function()
{
$.ajax({
type: "POST",
data: { meet: 1 , topic: 1 , encryption : ' <?php echo $this->security->get_csrf_hash(); ?>'},
url: " <?php echo base_url().'meet/open_content'?>",
success: function(data){
//数据data在这里
$("p#demo").html(data);
}
});
}
</script>
复制代码
-------------------这是控制器页面---------------------
PHP复制代码
<?php defined('BASEPATH') or exit('No direct script access allowed');
class Meet extends Front_Controller
{
function __construct ()
{
parent ::__construct ();
$this->load->model('meet_mdl');
// $this->load->library('form_validation');
// $this->load->helper("url");
// $this->load->helper("form");
}
function open_content ()
{
$meet_id=$this->input->post('meet');
$topic_id=$this->input->post('topic');
$content=$this->meet_mdl->view_meet_content($meet_id,$topic_id);
echo json_encode($content);
}
}
复制代码
我已经通过控制meet,topic两个参数完成了数据库调用,数据return在data里面。
以下是data数据
array (size=2)
0 => object(stdClass)[23]
public 'content_id' => string '1' (length=1)
public 'topic_id' => string '1' (length=1)
public 'meet_id' => string '1' (length=1)
public 'content_text' => string '11111111111111111111111111Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer fa'... (length=628)
public 'content_time' => string '111' (length=3)
public 'content_starter' => string '111111' (length=6)
1 => object(stdClass)[24]
public 'content_id' => string '2' (length=1)
public 'topic_id' => string '1' (length=1)
public 'meet_id' => string '1' (length=1)
public 'content_text' => string '2222222222222222222222222222Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer '.
public 'content_time' => string '111' (length=3)
public 'content_starter' => string '111111' (length=6)
现在我想在页面用表单把数组分类打印出来,如何做?
|
|