Skip to main content
edited body
Source Link
Ferhat
  • 115
  • 7
jQuery(document).ready(function () {
  let limit = 4;
  let start = 0;
  let action = 'inactive';

  function load_country_data(limit, start) {
    jQuery.ajax({
      url: "http://localhost/test/wp-admin/admin-ajax.php",
      method: "POST",
      data: {limit: limit, start: start, action: 'test'},
      cache: false,
      action: 'test',
      success: function (data) {
      jQuery('#load_data').append(data);
      if (data === '') {
      jQuery('#load_data_message').html("<button type='button'> No Data Found </button>");
         action = 'active';
       } else {
      jQuery('#load_data_message').html("<button type='button'> Please Wait... </button>")
         action = "inactive";

         }
       }
     });
  }

  if (action === 'inactive') {
  action = 'active';
  load_country_data(limit, start);
 }
 jQuery(window).scroll(function () {
  if (jQuery(window).scrollTop() + jQuery(window).height() > jQuery('#load_data').height() && 
   action == 'inactive') {
   action = 'active';
   start = start + limit;
   setTimeout(function () {
   load_country_data(limit, start);
     }, 1000);
    }
  });
});
jQuery(document).ready(function () {
  let limit = 4;
  let start = 0;
  let action = 'inactive';

  function load_country_data(limit, start) {
    jQuery.ajax({
      url: "http://localhost/test/wp-admin/admin-ajax.php",
      method: "POST",
      data: {limit: limit, start: start},
      cache: false,
      action: 'test',
      success: function (data) {
      jQuery('#load_data').append(data);
      if (data === '') {
      jQuery('#load_data_message').html("<button type='button'> No Data Found </button>");
         action = 'active';
       } else {
      jQuery('#load_data_message').html("<button type='button'> Please Wait... </button>")
         action = "inactive";

         }
       }
     });
  }

  if (action === 'inactive') {
  action = 'active';
  load_country_data(limit, start);
 }
 jQuery(window).scroll(function () {
  if (jQuery(window).scrollTop() + jQuery(window).height() > jQuery('#load_data').height() && 
   action == 'inactive') {
   action = 'active';
   start = start + limit;
   setTimeout(function () {
   load_country_data(limit, start);
     }, 1000);
    }
  });
});
jQuery(document).ready(function () {
  let limit = 4;
  let start = 0;
  let action = 'inactive';

  function load_country_data(limit, start) {
    jQuery.ajax({
      url: "http://localhost/test/wp-admin/admin-ajax.php",
      method: "POST",
      data: {limit: limit, start: start, action: 'test'},
      cache: false,
     
      success: function (data) {
      jQuery('#load_data').append(data);
      if (data === '') {
      jQuery('#load_data_message').html("<button type='button'> No Data Found </button>");
         action = 'active';
       } else {
      jQuery('#load_data_message').html("<button type='button'> Please Wait... </button>")
         action = "inactive";

         }
       }
     });
  }

  if (action === 'inactive') {
  action = 'active';
  load_country_data(limit, start);
 }
 jQuery(window).scroll(function () {
  if (jQuery(window).scrollTop() + jQuery(window).height() > jQuery('#load_data').height() && 
   action == 'inactive') {
   action = 'active';
   start = start + limit;
   setTimeout(function () {
   load_country_data(limit, start);
     }, 1000);
    }
  });
});
added 198 characters in body
Source Link
Ferhat
  • 115
  • 7

enter image description here

actually the data value should be empty, but it never goes into the if condition and always returns 0

enter image description here

actually the data value should be empty, but it never goes into the if condition and always returns 0

added 10 characters in body
Source Link
Ferhat
  • 115
  • 7
jQuery(document).ready(function () {
  let limit = 4;
  let start = 0;
  let action = 'inactive';

  function load_country_data(limit, start) {
    jQuery.ajax({
      url: "http://localhost/test/wp-admin/admin-ajax.php",
      method: "POST",
      data: {limit: limit, start: start},
      cache: false,
      action: 'test',
      success: function (data) {
      jQuery('#load_data').append(data);
      if (data === '') {
      $jQuery('#load_data_message').html("<button type='button'> No Data Found </button>");
         action = 'active';
       } else {
      $jQuery('#load_data_message').html("<button type='button'> Please Wait... </button>")
         action = "inactive";

         }
       }
     });
  }

  if (action === 'inactive') {
  action = 'active';
  load_country_data(limit, start);
 }
 jQuery(window).scroll(function () {
  if (jQuery(window).scrollTop() + jQuery(window).height() > jQuery('#load_data').height() && 
   action == 'inactive') {
   action = 'active';
   start = start + limit;
   setTimeout(function () {
   load_country_data(limit, start);
     }, 1000);
    }
  });
});
jQuery(document).ready(function () {
  let limit = 4;
  let start = 0;
  let action = 'inactive';

  function load_country_data(limit, start) {
    jQuery.ajax({
      url: "http://localhost/test/wp-admin/admin-ajax.php",
      method: "POST",
      data: {limit: limit, start: start},
      cache: false,
      action: 'test',
      success: function (data) {
      jQuery('#load_data').append(data);
      if (data === '') {
      $('#load_data_message').html("<button type='button'> No Data Found </button>");
         action = 'active';
       } else {
      $('#load_data_message').html("<button type='button'> Please Wait... </button>")
         action = "inactive";

         }
       }
     });
  }

  if (action === 'inactive') {
  action = 'active';
  load_country_data(limit, start);
 }
 jQuery(window).scroll(function () {
  if (jQuery(window).scrollTop() + jQuery(window).height() > jQuery('#load_data').height() && 
   action == 'inactive') {
   action = 'active';
   start = start + limit;
   setTimeout(function () {
   load_country_data(limit, start);
     }, 1000);
    }
  });
});
jQuery(document).ready(function () {
  let limit = 4;
  let start = 0;
  let action = 'inactive';

  function load_country_data(limit, start) {
    jQuery.ajax({
      url: "http://localhost/test/wp-admin/admin-ajax.php",
      method: "POST",
      data: {limit: limit, start: start},
      cache: false,
      action: 'test',
      success: function (data) {
      jQuery('#load_data').append(data);
      if (data === '') {
      jQuery('#load_data_message').html("<button type='button'> No Data Found </button>");
         action = 'active';
       } else {
      jQuery('#load_data_message').html("<button type='button'> Please Wait... </button>")
         action = "inactive";

         }
       }
     });
  }

  if (action === 'inactive') {
  action = 'active';
  load_country_data(limit, start);
 }
 jQuery(window).scroll(function () {
  if (jQuery(window).scrollTop() + jQuery(window).height() > jQuery('#load_data').height() && 
   action == 'inactive') {
   action = 'active';
   start = start + limit;
   setTimeout(function () {
   load_country_data(limit, start);
     }, 1000);
    }
  });
});
Source Link
Ferhat
  • 115
  • 7
Loading