Why not change AJAX check to keyup and avoid blur?
-
Many sites need automatic typing. Why not change your JavaScript function inside file
username-availability-checker.js
to look like this?var debounce__BDUAChecker; jq( document).on( 'keyup', _BDUAChecker.selectors, function() { if(debounce__BDUAChecker) clearTimeout(debounce__BDUAChecker); var $__this = this, $this = jq( $__this ), $wrapper = $this.parent('.username_checker'); jq( '.loading', $wrapper ).css( {display:'block'} ); debounce__BDUAChecker = setTimeout(function(){ if( ! $wrapper.get(0) ) { $wrapper = create_wrapper( $__this ); } jq( '.name-info', $wrapper ).empty();//hhide the message //show loading icon jq( '.loading', $wrapper ).css( {display:'block'} ); var user_name = $this.val(); jq.post( ajaxurl, { action: 'check_username', cookie: encodeURIComponent(document.cookie), user_name: user_name }, function( resp ) { if( resp && resp.code != undefined && resp.code == 'success' ) { show_message( $wrapper, resp.message, 0 ); } else { show_message( $wrapper, resp.message, 1 ); } }, 'json' ); },250); });//end of keyup
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Why not change AJAX check to keyup and avoid blur?’ is closed to new replies.