speeding up response.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Claus Mygind
    Contributor
    • Mar 2008
    • 571

    speeding up response.

    In an effort to make my apps run faster, I have started to embed a search feature into the html page with javaScript to call and execute an ajax routine. Everything works fine except for setting focus to the first (and only) input element.
    Code:
    //~~~~~ Display search box ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    function showPopSearch( ) {
    	if (  document.getElementById("popSearch").style.visibility == "hidden" ) {
    		document.getElementById("popSearch").style.backgroundColor = "#E4BF87";
    		document.getElementById("popSearch").style.borderStyle = "ridge";
    		document.getElementById("popSearch").style.borderWidth = "5px";
    		document.getElementById("popSearch").style.borderColor = "orange";
    		document.getElementById("popSearch").style.zIndex = "99";
    		document.getElementById("popSearch").style.visibility = "visible";
    		document.getElementById("popSearch").style.overflow = "hidden";
    
    //to make this brief showGetSearch() is not shown here
    		showGetSearch( );
    
    //I have to use this timeout or it will run right past the giveSeachFocus( )
    		var TimeoutID = setTimeout("giveSearchFocus()", 150);
    	}
    }
    
    //~~~~~ Give Search element focus ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    function giveSearchFocus(){
    	document.getElementById("SEARCH").select();
    	document.getElementById("SEARCH").focus();
    }
    The problem is sometimes, the cursor is there instantaneously other times it can take several seconds for it to appear. The users are annoyed that they cannot start typing right away. How can I resolve this issue and always have the cursor appear right away?
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5388

    #2
    can you confirm that the field has NO focus or is the focus just 'invisible' ... so you could type instantly ... but just don't notice the focus? this problem seems to be common and i never saw a solution ... but you could 'workaround' it with setting a border around focused fields or a background-color ... so that the focus could be easily noticed ... the cursor alone seems to be a not quite good indicator ... but may be someone has a better solution?

    kind regards

    Comment

    • Claus Mygind
      Contributor
      • Mar 2008
      • 571

      #3
      It is visible, you just cannot type in it until the cursor appears.

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5388

        #4
        then there are some synchronous requests like large js-libs, frames etc.? that might be loaded the same time?

        Comment

        • Claus Mygind
          Contributor
          • Mar 2008
          • 571

          #5
          when I try this

          Code:
          	
          document.getElementById("SEARCH").style.background-color = "yellow";
          I get this error.

          invalid assignment left-hand side
          [Break on this error] document.getEle mentById("SEARC H").style.backg round-color = "yellow";\n

          But I was able to do this to verify that the cursor was red
          Code:
          document.getElementById("SEARCH").select();
          document.getElementById("SEARCH").focus();
          document.getElementById("SEARCH").style.color = "red";

          Comment

          • gits
            Recognized Expert Moderator Expert
            • May 2007
            • 5388

            #6
            it has to be:

            [CODE=javascript]document.getEle mentById("SEARC H").style.backg roundColor [/CODE]
            kind regards

            Comment

            • Claus Mygind
              Contributor
              • Mar 2008
              • 571

              #7
              Ok I got the back ground color established to check. I can now say that the cursor and color are both delayed.

              I have also established that the problem occurs when switching from one type of search request to another. I have several places on each screen where a user can request (click on) a search i.e. they can click on the company Id or company name. The same number of parameters are sent to the search request in either case.

              Code:
              onmousedown="if (CheckForChange(this.form,'no')) {showPopSearch(event,'Client Id','10','8','client','by Id','id','no','client)};"
              
              onmousedown="if (CheckForChange(this.form,'no')) {showPopSearch(event,'Client Name','60','50','client','by Name','Name','no','client)};"
              As you can see the calls are identical except for the parameters.

              On the initial request the popup is instantaneous. But if the user then select a 2nd search request on a different link the delay will occur?

              How can I track where the slowdown is occurring. I am using FireFox with Firebug, so I can see response when the page loads but not the execution time of the scripts after the page is loaded, at least I don't know how.

              Comment

              • gits
                Recognized Expert Moderator Expert
                • May 2007
                • 5388

                #8
                typically there are just two simultanous http-requests allowed ... does the problem occur with two or just more requests? you could either abort the running requests or just don't check every field aqainst the backend through preloading some more data ...

                Comment

                • Claus Mygind
                  Contributor
                  • Mar 2008
                  • 571

                  #9
                  There would always be only one request running at the time.

                  Comment

                  • gits
                    Recognized Expert Moderator Expert
                    • May 2007
                    • 5388

                    #10
                    ?? how is this ensured ?? you just said that you could search something and simultanously search for another thing ... is it sure that any search is not started before an already started one has returned? does any errors occur in firebug during the requests or response-handlings?

                    Comment

                    • Claus Mygind
                      Contributor
                      • Mar 2008
                      • 571

                      #11
                      Thank you for your kind reply. Sorry for the delayed response, I am not a full time employee so I do not read these posts everyday.

                      You ask how can I ensure that only one search occurs at the time. Well the search is initiated by the user by clicking on one of several buttons. They are not likely to click on a 2nd button before they have completed the first search. The action of clicking on a button brings up the dialogue box into which the user has to enter the requested search information i.e. enter clients name. Then they click another button on the dialogue box to start the search. This action brings a response to the search dialogue box or responds "no records found". Therefore it is unlikely that they would stop the action of the first search and start a second search.

                      Besides at this point I am the one testing why the response is slow. And I know that I am only calling on search at the time.

                      I think you have pointed me to an area to look at, that being what is happening in my code when I change search criteria. So I will continue my search in the code for the answer.

                      Comment

                      • gits
                        Recognized Expert Moderator Expert
                        • May 2007
                        • 5388

                        #12
                        hmmmm ... with a popup it even shouldn't be a problem in case it is a window ... every window handles its own requests (as far as i know) ... when closing it the request should be aborted. so it may be that there is something 'strange' when constructing the request ... in case you find something and need help with it just post back here :)

                        kind regards

                        Comment

                        Working...