Javascript 在一个模式AjAX Codeigient中显示不同的库
您好,我想知道如何为我单击的每个按钮显示不同的图库。以下是我的查看代码:Javascript 在一个模式AjAX Codeigient中显示不同的库,javascript,php,ajax,twitter-bootstrap,codeigniter,Javascript,Php,Ajax,Twitter Bootstrap,Codeigniter,您好,我想知道如何为我单击的每个按钮显示不同的图库。以下是我的查看代码: <div id="gallery-buttons"> <div class="row"> <div class="col-md-2 col-md-offset-3"> <p>Eagle Fruit South Africa</p> <img
<div id="gallery-buttons">
<div class="row">
<div class="col-md-2 col-md-offset-3">
<p>Eagle Fruit South Africa</p>
<img src="<?= base_url() ?>assets/img/site/apple.png" class="img-responsive" id="apple"
alt="apple"/>
<button type="button" onclick="saBtn()" class="btn btn-primary btn-sm" id="saBtn">View Gallery
</button>
</div>
<div class="col-md-2">
<p>Eagle Fruit Kenya</p>
<img src="<?= base_url() ?>assets/img/site/avo.png" class="img-responsive" id="strawberry"
alt="avocado"/>
<button type="button" onclick="kenyaBtn()" class="btn btn-primary btn-sm" id="kenyaBtn">View
Gallery
</button>
</div>
<div class="col-md-2">
<p>Eagle Fruit Egypt</p>
<img src="<?= base_url() ?>assets/img/site/strawberry.png" id="eorange" class="img-responsive"
alt="strawberry"/>
<button type="button" onclick="egyptBtn()" class="btn btn-primary btn-sm" id="egyptBtn">View
Gallery
</button>
</div>
</div>
</div>
</div>
我的模型中有以下设置:
function get_sa(){
$this->db->select('*');
$this->db->from('gallery');
$this->db->join('gallery_images', 'gallery_images.gallery_id = gallery.name','left');
$this->db->where('gallery.gallery_name' == 'South Africa');
$query = $this->db->get();
return $query->result('array');
}
function get_egypt(){
$this->db->select('*');
$this->db->from('gallery');
$this->db->join('gallery_images', 'gallery_images.gallery_id = gallery.name','left');
$this->db->where('gallery.gallery_name' == 'Egypt');
$query = $this->db->get();
return $query->result('array');
}
function get_kenya(){
$this->db->select('*');
$this->db->from('gallery');
$this->db->join('gallery_images', 'gallery_images.gallery_id = gallery.name','left');
$this->db->where('gallery.gallery_name' == 'Kenya');
$query = $this->db->get();
return $query->result('array');
}
那么现在我如何将结果传递给modal并构建库呢?使用AJAX从codeigniter获取结果
function get_sa(){
$this->db->select('*');
$this->db->from('gallery');
$this->db->join('gallery_images', 'gallery_images.gallery_id = gallery.name','left');
$this->db->where('gallery.gallery_name' == 'South Africa');
$query = $this->db->get();
return $query->result('array');
}
function get_egypt(){
$this->db->select('*');
$this->db->from('gallery');
$this->db->join('gallery_images', 'gallery_images.gallery_id = gallery.name','left');
$this->db->where('gallery.gallery_name' == 'Egypt');
$query = $this->db->get();
return $query->result('array');
}
function get_kenya(){
$this->db->select('*');
$this->db->from('gallery');
$this->db->join('gallery_images', 'gallery_images.gallery_id = gallery.name','left');
$this->db->where('gallery.gallery_name' == 'Kenya');
$query = $this->db->get();
return $query->result('array');
}