Advertisement
sh1fralf4tih

views ajax

Dec 24th, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.34 KB | None | 0 0
  1. <!doctype html>
  2. <!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang=""> <![endif]-->
  3. <!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8" lang=""> <![endif]-->
  4. <!--[if IE 8]>         <html class="no-js lt-ie9" lang=""> <![endif]-->
  5. <!--[if gt IE 8]><!--> <html class="no-js" lang=""> <!--<![endif]-->
  6. <head>
  7.     <meta charset="utf-8">
  8.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  9.     <title>Ela Admin - HTML5 Admin Template</title>
  10.     <meta name="description" content="Ela Admin - HTML5 Admin Template">
  11.     <meta name="viewport" content="width=device-width, initial-scale=1">
  12.  
  13.     <link rel="apple-touch-icon" href="https://i.imgur.com/QRAUqs9.png">
  14.     <link rel="shortcut icon" href="https://i.imgur.com/QRAUqs9.png">
  15.  
  16.     <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/normalize.css@8.0.0/normalize.min.css">
  17.     <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.1.3/dist/css/bootstrap.min.css">
  18.     <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css">
  19.     <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/lykmapipo/themify-icons@0.1.2/css/themify-icons.css">
  20.     <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/pixeden-stroke-7-icon@1.2.3/pe-icon-7-stroke/dist/pe-icon-7-stroke.min.css">
  21.     <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/3.2.0/css/flag-icon.min.css">
  22.     <link rel="stylesheet" href="<?php echo base_url();?>/assets/css/cs-skin-elastic.css">
  23.     <link rel="stylesheet" href="<?php echo base_url();?>/assets/css/style.css">
  24.  
  25.     <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800' rel='stylesheet' type='text/css'>
  26.  
  27.     <!-- <script type="text/javascript" src="https://cdn.jsdelivr.net/html5shiv/3.7.3/html5shiv.min.js"></script> -->
  28. </head>
  29. <body class="bg-dark">
  30.  
  31.     <div class="sufee-login d-flex align-content-center flex-wrap">
  32.         <div class="container">
  33.             <div class="login-content">
  34.                 <div class="login-logo">
  35.                     <a href="index.html">
  36.                         <img class="align-content" src="<?php echo base_url();?>/assets/images/logo.png" alt="">
  37.                     </a>
  38.                 </div>
  39.                 <div class="login-form">
  40.                     <form>
  41.                         <div id='error_message'>PESAN MUNCUL DISINI</div>
  42.                         <div id='error'>KODE ERROR DISINI</div>
  43.                         <div class="form-group">
  44.                             <label>NO RESELLER</label>
  45.                             <input type="text" class="form-control" name="nors" id="nors" placeholder="NO RESELLER">
  46.                         </div>
  47.                         <div class="form-group">
  48.                             <label>ID DIGIPOS</label>
  49.                             <input type="text" name="digiposid" class="form-control" id="digiposid" placeholder="ID DIGIPOS">
  50.                         </div>
  51.                         <div class="form-group">
  52.                             <label>Password</label>
  53.                             <input type="password" name="password" class="form-control" id="password" placeholder="Password">
  54.                         </div>
  55.                         <div class="form-group">
  56.                             <label>Nama Toko</label>
  57.                             <input type="text" name="nmtoko" class="form-control" id="nmtoko" placeholder="Nama Toko">
  58.                         </div>
  59.                         <button type="submit" onclick="reload2()" class="btn btn-primary btn-flat m-b-30 m-t-30">Register</button>
  60.                         <div class="register-link m-t-15 text-center">
  61.                             <p>Already have account ? <a href="<?php echo site_url('Welcome');?>"> Sign in</a></p>
  62.                         </div>
  63.                     </form>
  64.                 </div>
  65.             </div>
  66.         </div>
  67.     </div>
  68.  
  69.     <script src="https://cdn.jsdelivr.net/npm/jquery@2.2.4/dist/jquery.min.js"></script>
  70.     <script src="https://cdn.jsdelivr.net/npm/popper.js@1.14.4/dist/umd/popper.min.js"></script>
  71.     <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.1.3/dist/js/bootstrap.min.js"></script>
  72.     <script src="https://cdn.jsdelivr.net/npm/jquery-match-height@0.7.2/dist/jquery.matchHeight.min.js"></script>
  73.     <script src="<?php echo base_url();?>/assets/js/main.js"></script>
  74.     <script type="text/javascript">
  75.         url = "<?php echo site_url('Auth/Register');?>";
  76.  
  77.         function reload2() {
  78.           data = {
  79.             'nors': document.getElementById('nors').value,
  80.             'digiposid': document.getElementById('digiposid').value,
  81.             'nmtoko': document.getElementById('nmtoko').value,
  82.             'password': document.getElementById('password').value
  83.           }
  84.           console.log(data);
  85.           obj = ajaxPostJson(url, data, false);
  86.           console.log(obj);
  87.           if (obj.error != false) {
  88.             document.getElementById('error').innerHTML = obj.status;
  89.             document.getElementById('error_message').innerHTML = obj.message;
  90.           } else {
  91.             res = obj.result;
  92.             document.getElementById('error').innerHTML = res.error;
  93.             document.getElementById('error_message').innerHTML = res.error_message;
  94.           }
  95.         }
  96.  
  97.         //=================core js =
  98.         function ajaxGetShowId(url, targetId, async = true, debug = 0) {
  99.           var xhttp = xmlHttp();
  100.  
  101.           if (async != true) async = false;
  102.           xhttp.open("GET", url, async);
  103.           xhttp.onreadystatechange = function() {
  104.             if (debug == 1) {
  105.               console.log(xhttp);
  106.             }
  107.             if (xhttp.readyState != 4 || xhttp.status != 200) {
  108.               return 0;
  109.             } else {
  110.               document.getElementById(targetId).innerHTML = xhttp.responseText;
  111.             }
  112.           };
  113.           xhttp.send();
  114.           /*bila TIDAK menggunakan async maka bisa mengembalikan hasil*/
  115.           response = {
  116.             detail: xhttp,
  117.             text: xhttp.responseText,
  118.             state: xhttp.readyState,
  119.             status: xhttp.status,
  120.             url: xhttp.responseURL,
  121.             type: xhttp.responseType
  122.           }
  123.           return response;
  124.         }
  125.  
  126.         function ajaxGetJson(url, async = false, debug = 0) {
  127.           var xhttp = xmlHttp();
  128.  
  129.           if (async != true) async = false;
  130.           xhttp.open("GET", url, async);
  131.           xhttp.onreadystatechange = function() {
  132.             if (debug == 1) {
  133.               console.log(xhttp);
  134.             }
  135.             if (xhttp.readyState != 4 || xhttp.status != 200) {
  136.               return 0;
  137.             }
  138.           };
  139.           xhttp.send();
  140.           response = {
  141.             state: xhttp.readyState,
  142.             status: xhttp.status,
  143.             url: xhttp.responseURL,
  144.             type: xhttp.responseType
  145.           }
  146.           text = xhttp.responseText;
  147.           try {
  148.             json = JSON.parse(text);
  149.             response.result = json;
  150.             response.error = false;
  151.             response.message = 'OK';
  152.           } catch (err) {
  153.             response.result = false;
  154.             response.error = err;
  155.             response.message = err.message;
  156.           }
  157.           return response;
  158.         }
  159.  
  160.         function ajaxPostJson(url, data = array(), async = false, debug = 0) {
  161.           var xhttp = xmlHttp();
  162.  
  163.           if (async != true) async = false;
  164.           xhttp.open("POST", url, async);
  165.           //    xhttp.setRequestHeader('Content-Type', 'application/json');
  166.           xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  167.  
  168.           xhttp.onreadystatechange = function() {
  169.             if (debug == 1) {
  170.               console.log(xhttp);
  171.             }
  172.             if (xhttp.readyState != 4 || xhttp.status != 200) {
  173.               return 0;
  174.             }
  175.           };
  176.           params = param(data);
  177.           console.log(params);
  178.           xhttp.send(params); //JSON.stringify(data) );
  179.           response = {
  180.             state: xhttp.readyState,
  181.             status: xhttp.status,
  182.             url: xhttp.responseURL,
  183.             type: xhttp.responseType
  184.           }
  185.           text = xhttp.responseText;
  186.           try {
  187.             json = JSON.parse(text);
  188.             response.result = json;
  189.             response.error = false;
  190.             response.message = 'OK';
  191.           } catch (err) {
  192.             response.result = false;
  193.             response.error = err;
  194.             response.message = err.message;
  195.           }
  196.           return response;
  197.         }
  198.  
  199.         function xmlHttp() {
  200.           if (window.XMLHttpRequest) {
  201.             xhttp = new XMLHttpRequest();
  202.           } else {
  203.             // code for IE6, IE5
  204.             xhttp = new ActiveXObject("Microsoft.XMLHTTP");
  205.             //new ActiveXObject("MSXML2.XMLHTTP.3.0")  
  206.           }
  207.           return xhttp;
  208.         }
  209.  
  210.         function param(object) {
  211.           var encodedString = '';
  212.           for (var prop in object) {
  213.             if (object.hasOwnProperty(prop)) {
  214.               if (encodedString.length > 0) {
  215.                 encodedString += '&';
  216.               }
  217.               encodedString += encodeURI(prop + '=' + object[prop]);
  218.             }
  219.           }
  220.           return encodedString;
  221.         }
  222.  
  223.     </script>
  224. </body>
  225. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement