javascript - I want to show a message while fetching results -


i have javascript code search db , show results. want to show message "please wait.." while fetching results. have written in line 3 (from last).

i mean, want show "please wait..." message in search-results div while getting results. not showing message.

function ajaxfunction(e) {     function r() {         if (t.readystate == 4) {             document.getelementbyid("search-results").innerhtml = t.responsetext;             document.getelementbyid("msg").style.display = "none"         }     }     var t;     try {         t = new xmlhttprequest     } catch (n) {         try {             t = new activexobject("msxml2.xmlhttp")         } catch (n) {             try {                 t = new activexobject("microsoft.xmlhttp")             } catch (n) {                 alert("your browser not support ajax!");                 return false             }         }     }     var = "search.php";     = + "?name=" + e;     = + "&sid=" + math.random();     t.onreadystatechange = r;     t.open("get", i, true);     t.send(null);     document.getelementbyid("msg").innerhtml = "please wait ...";     document.getelementbyid("msg").style.display = "inline" } 

problem solved

update.

i want job when input reaches 10 characters.

html code

<input type="text" name="name" maxlength="10" id="name" onkeyup="ajaxfunction(this.value);" /> 

think need add somthing r():

if (t.readystate == 4) {             document.getelementbyid("search-results").innerhtml = t.responsetext;             document.getelementbyid("msg").style.display = "none"         }  if (t.readystate == 1 ||t.readystate == 2 ||t.readystate == 3) {                      document.getelementbyid("msg").style.display = "block";         } 

....so shown while connecting/receiving/prossesing. might not have hidden before, messesages following requests not shown


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -