Advertisement
Guest User

load_view.php

a guest
Apr 26th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.92 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="utf-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1">
  7.     <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
  8.     <title>Codeigniter page scroll load more </title>
  9.  
  10.     <!-- Bootstrap -->
  11.     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  12.  
  13.     <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  14.     <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  15.     <!--[if lt IE 9]>
  16.     <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  17.     <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  18.     <![endif]-->
  19. </head>
  20. <body>
  21. <div class="container">
  22.     <div class="alert alert-info" style="position: fixed; width: 1140px";>
  23.         <h4 style="color: #000000;">Codeigniter load more data on click article</h4>
  24.         <!-- <small>By vikram parihar <a href="http://webrocom.net">webrocom.net</a> </small> -->
  25.     </div>
  26. </div>
  27. <div class="container" style="margin-top: 120px;">
  28.     <h3>Ajax country list</h3>
  29.     <table class="table">
  30.         <thead>
  31.         <tr><th>SN</th><th>Country name</th><th>Country code</th></tr>
  32.         </thead>
  33.  
  34.         <tbody id="ajax_table">
  35.         </tbody>
  36.     </table>
  37.     <div class="container" style="text-align: center"><button class="btn" id="load_more" data-val = "0">Load more..<img style="display: none" id="loader" src="<?php echo str_replace('index.php','',base_url()) ?>asset/loader.GIF"> </button></div>
  38. </div>
  39.  
  40. <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
  41. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  42. <!-- Include all compiled plugins (below), or include individual files as needed -->
  43. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
  44.  
  45. <script>
  46.     $(document).ready(function(){
  47.         getcountry(0);
  48.  
  49.         $("#load_more").click(function(e){
  50.             e.preventDefault();
  51.             var page = $(this).data('val');
  52.             getcountry(page);
  53.  
  54.         });
  55.  
  56.     });
  57.  
  58.     var getcountry = function(page){
  59.         $("#loader").show();
  60.         $.ajax({
  61.             url:"<?php echo base_url() ?>index.php/load_more/getCountry",
  62.             type:'GET',
  63.             data: {page:page}
  64.         }).done(function(response){
  65.             $("#ajax_table").append(response);
  66.             $("#loader").hide();
  67.             $('#load_more').data('val', ($('#load_more').data('val')+1));
  68.             scroll();
  69.         });
  70.     };
  71.  
  72.     var scroll  = function(){
  73.         $('html, body').animate({
  74.             scrollTop: $('#load_more').offset().top
  75.         }, 1000);
  76.     };
  77.  
  78.  
  79. </script>
  80. </body>
  81. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement