apl-mhd

jQuery Live data search

Nov 4th, 2018
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.99 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <!--suppress ALL -->
  3. <html>
  4. <head>
  5.     <title></title>
  6.  
  7.     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  8.  
  9.  
  10.  
  11. </head>
  12. <body>
  13.  
  14. <ul id="info"></ul>
  15.  
  16.  
  17. <p> Name: <input type="text"  value="apel" id="name"> </p>
  18. <p> Drink: <input type="text" id="drink"> </p>
  19.  
  20.  
  21. <button id="click">Click</button>
  22.  
  23. <div id="result">
  24.  
  25.  
  26. </div>
  27.  
  28.  
  29. <script type="text/javascript">
  30.     $(document).ready(function () {
  31.  
  32.  
  33.  
  34.         $( '#name' ).keyup(function() {
  35.  
  36.             var  inputName = $( '#name' ).val();
  37.             //console.log(inputName);
  38.  
  39.             $('#result').load('test.php table', {name:inputName});
  40.         });
  41.  
  42.  
  43.         /*
  44.                 $('#name').keypress(function () {
  45.                     console.log('apel');
  46.                 }),
  47.         */
  48.  
  49.  
  50.         $('#click').on('click',function () {
  51.  
  52.             $('#result').load('test.php table', {name:'A'});
  53.         });
  54.  
  55.  
  56. /*
  57.         $.ajax({
  58.             url: "test.php",
  59.             cache: false
  60.         })
  61.             .done(function( html ) {
  62.              // console.log(nameid);
  63.  
  64.                 $( "#result" ).append( html );
  65.             });*/
  66.     });
  67.  
  68.  
  69.  
  70.     /*$(document).ready(function () {
  71.         var x = {
  72.             name :'orko',
  73.             hobi: 'photograpy'
  74.     }
  75.  
  76.     console.log(x)
  77.  
  78.  
  79.         $.get("https://unsplash.com/t/wallpapers", function(html){
  80.             var txt = $(html).find('a');
  81.  
  82.  
  83.             for (i=0; i<txt.length;i++) {
  84.  
  85.                var link= txt[i].title.split(' ').join('');
  86.  
  87.                if( link == 'Downloadphoto' ) {
  88.  
  89.  
  90.                    var img = '<img style="width:  100px; height: 100px;" src='+ txt[i].href +'>';
  91.  
  92.                     $('#result').append(img);
  93.  
  94.                     console.log(txt[i].href);
  95.  
  96.                 }
  97.  
  98.             }
  99.  
  100.             console.log(txt.length);
  101.  
  102.            // $("#wikiModal h4.modal-title").text(txt);
  103.         });
  104.  
  105.  
  106.     });*/
  107.  
  108.     /*var $list = $('#info');
  109.  
  110.     var $name = $('#name');
  111.     var $drink = $('#drink');
  112.  
  113.     $(function () {
  114.  
  115.         $.ajax({
  116.             type: 'GET',
  117.             dataType: 'json',
  118.             url: 'info.json',
  119.             success: function (datas) {
  120.  
  121.                 $.each(datas, function (i, data) {
  122.  
  123.                     $list.append( '<li>'+  data.name  +'</li>');
  124.  
  125.                     console.log(data.age);
  126.                 })
  127.             }
  128.         });
  129.  
  130.         $('#add').on('click', function () {
  131.             var  order ={
  132.  
  133.                 drink: $drink.val(),
  134.                 name: $name.val(),
  135.  
  136.             };
  137.  
  138.          $.ajax({
  139.  
  140.              type: 'POST',
  141.              url: 'info.json',
  142.              data: order,
  143.              
  144.              success:function (newOrder) {
  145.  
  146.                  $list.append( '<li>'+  newOrder  +'</li>');
  147.              },
  148.  
  149.              error:function () {
  150.  
  151.                  console.log('error');
  152.              }
  153.  
  154.          })
  155.  
  156.         })
  157.  
  158.     })*/
  159.  
  160. </script>
  161.  
  162. </html>
Add Comment
Please, Sign In to add comment