Advertisement
akkauntnimagadir

funksiyalarim

Feb 7th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(function () {
  2.     $('#btn_user').click(function () {
  3.  
  4.         $.ajax({
  5.             url: 'https://jsonplaceholder.typicode.com/users',
  6.             method: 'GET',
  7.             beforeSend: function (jqXHR, settings) {
  8.                 $('#btn_user').attr('disabled', 'disabled').find('i').addClass('fa-spin');
  9.                 $('#card-body').empty().append('<div class="col-md-12">\n' +
  10.                     '<h5 class="text-center"> <i class="fa fa-hourglass-half fa-spin"></i> Users loading .. . </h5>\n' +
  11.                     ' </div>')
  12.             },
  13.             success: function (users, textStatus, jqXHR) {
  14.                 $('#card-body').empty().append('<ul class="list-group" id="userList"></ul>');
  15.                 $('#btn_user').removeAttr('disabled').find('i').removeClass('fa-spin');
  16.                 $.each(users, function (i, user) {
  17.                     $('#userList').append('<li class="list-group-item" id="' + user.id + '">' + user.id + '. ' + user.name + '</li><button class="btn btn-danger"></button>')
  18.                 })
  19.  
  20.  
  21.             }
  22.  
  23.         })
  24.     })
  25. });
  26.  
  27. $(function () {
  28.     $('.btn').click(function () {
  29.         alert('bosildi');
  30.         var tempID = $(this).attr('id');
  31.         $.ajax({
  32.  
  33.  
  34.             url: 'https://jsonplaceholder.typicode.com/posts?userId=1',
  35.             // url: 'https://jsonplaceholder.typicode.com/posts', data:{userID: tempID},
  36.             // url: 'https://jsonplaceholder.typicode.com/posts?userID=' + tempID,
  37.             method: 'GET',
  38.             beforeSend: function (jqXHR, settings) {
  39.                 $('#infoField').empty().append('<div class="col-md-12">\n' +
  40.                     '<h5 class="text-center"> <i class="fa fa-spinner fa-spin"></i> Please wait .. . </h5>\n' +
  41.                     ' </div>')
  42.             },
  43.             success: function (posts, textStatus, jqXHR) {
  44.                 $('#infoField').empty();
  45.                 $.each(posts,function (i, post) {
  46.                     $('#infoField').append(' <div class="card-hea   der bg-secondary"> User1'+tempID+'s Posts</div>\n' +
  47.                         '<div class="card-body">\n' +
  48.                         '    <strong>Title:'+post.title+'</strong>\n' +
  49.                         '    <strong>Body:'+post.body+'</strong>\n' +
  50.                         '</div>')
  51.                 })
  52.             }
  53.         });
  54.  
  55.     });
  56.  
  57. });
  58.  
  59. // function idnioldimi() {
  60. //     var tempID = $(this).attr('id');
  61. //     $('#infoField').append(tempID)
  62. //     console.log(tempID);
  63. // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement