Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##### view #####
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- <script type="text/javascript" src="<?php echo base_url('plugins/js/jquery-3.1.1.min.js')?>"></script>
- <script type="text/javascript">
- $(document).ready(function(){
- $("#butao").click(function(){
- var url = <?php site_url('welcome/ajax') ?>;
- var data = <?php $dados; ?>
- $.ajax({
- url: url,
- type:"POST",
- data: 'data',
- success:function(resultado){
- $(".ajax").html(resultado);
- }
- });
- });
- });
- </script>
- </head>
- <body>
- <textarea class="ajax"></textarea>
- <button id="butao">crud</button>
- </body>
- </html>
- ### Controller ####
- public function ajax(){
- $this->load->model('crud');
- $result['dados'] = $this->crud->getall();
- $this->load->view('ajax', $result) ;
- }
- ### Model ###
- public function getall(){
- $result = $this->db->get('tbl_artigo');
- return $result->result();
- }
- #### Fim ###
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement