Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8075963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:09:51+00:00 2026-06-05T15:09:51+00:00

function checkuser(user) { var ret = false; $.ajax({ type:’POST’, url:’user.php’, async:false, data:{‘user’:user}, success:function (data)

  • 0
function checkuser(user) {
        var ret = false;
        $.ajax({ type:'POST', url:'user.php',
            async:false,
            data:{'user':user},
            success:function (data) {
                if (data == 1) ret = true
            } });

        return ret;
    }

I use bvalidator to validate fields. It seems to fire this function on every keypress and the user is not able to continue typing before the ajax call is competed. I’m not really sure what to do here.

How could I make the function not be ran more than once every two seconds for example?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T15:09:53+00:00Added an answer on June 5, 2026 at 3:09 pm

    You need to get rid of async:false but you also need to modify your code to work asynchronously. The synchronicity is what is causing your UI to ‘freeze’.

    Maybe you could try setting a timeout that will run 2 seconds after a key is pressed on your input, but if another key is pressed it restarts that timer. So in essence it will only after two seconds of no keystrokes.

    var validateTimeout;
    
    $('#target').keydown(function() {
      clearTimeout(validateTimeout);
      validateTimeout = setTimeout(function(){checkuser(user);},2000);
    });
    

    You’ll need to update the checkuser ajax call to have a smarter callback to work async:

    function checkuser(user) {
        $.ajax({ type:'POST', url:'user.php',
            async:false,
            data:{'user':user},
            success:function (data) {
                if(data == 1){
                  //something to indicate sucess
                }else{
                 //something to indicate failure
                }
            } });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

function stationMenu($scope){ $.ajax({ url: /users/station_names_ajax, type: POST, success: function(data){ $scope.phones = [ {name: Nexus
function parseAttach(b) { var h=; for(i=0;i<b.length;i++) { var a=b[i]; switch(a['type']) { case image: h+='<li
I wrote this function in php to check user/pass against account on linux server.
function something(frm,i){ //var ch=frm.outof1.value; for(var j=1;j<=i;j++) { //var b=outof + j; alert(frm.outof+j.value); } //alert(outof
function deleteRecordDialog() { var returnThis; var numRecordss = recs.length; var html = /*html= html
I have this query: public function checkUser($phone) { $sql = SELECT name FROM users
I have combined itechroom checkUserName function with JohnP's run js after user finished typing
javascript(jquery) $('.ic_parent').change(function(){ var id = $(this).attr('value') while (id.length >0){ if ($(this).attr('checked')) { $('#update_ics_table').find('input:checkbox[id =
I'm using PHP function virtual() for sending files by Apache 2.2 (it works faster
I'm writing a script where by a user registers his/her username, but a function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.