collecting medal for hitxy members
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

57 lines
1.4KB

  1. (function ($) {
  2. // http://davidwalsh.name/javascript-debounce-function
  3. function debounce(func, wait, immediate) {
  4. var timeout;
  5. return function () {
  6. var context = this, args = arguments;
  7. var later = function () {
  8. timeout = null;
  9. if (!immediate)
  10. func.apply(context, args);
  11. };
  12. var callNow = immediate && !timeout;
  13. clearTimeout(timeout);
  14. timeout = setTimeout(later, wait);
  15. if (callNow)
  16. func.apply(context, args);
  17. };
  18. };
  19. /*______________________________________________________*/
  20. $(function () {
  21. $('#test').html(mm.display_name);
  22. console.log(mm);
  23. });
  24. function errUserName(msg)
  25. {
  26. var el = $("#errUserName");
  27. el.html(msg);
  28. el.fadeIn();
  29. setTimeout(function(){
  30. el.fadeOut();
  31. }, 2000);
  32. }
  33. $(document).on("click", "#step1", function(){
  34. var input = $("#username").val();
  35. if ( input == "" ){
  36. errUserName(" cannot be empty");
  37. return;
  38. }
  39. $.post(mm.ajax_url, { // POST request
  40. _ajax_nonce: mm.nonce, // nonce
  41. action: "list_users", // action
  42. client : input,
  43. }, function(response, status, xhr){
  44. alert(response.id);
  45. }).fail(function(){
  46. alert('network error ');
  47. });
  48. });
  49. })(jQuery);