Jquery and Ajax problem

Associate
Joined
28 May 2008
Posts
346
Hi guys i have created a SIAB site for a uni project (Shakesphere in a browser) loading in xml data using JQuery and Ajax, have a problem with the search where it brings up random numbers like "0" and "47" at the front of the search results, have checked the source of the code and these rogue numbers don't seem to belong to any HTML element on the page. Il post my search code and a screenshot, any help would be greatly apprecicated. Thanks.

Code:
function searchResults(query){              
        var temp = "\\b" + query + "\\b";         
        var regex_query = new RegExp(temp,"gi");  
        var currentLine;
        var num_matching_lines = 0;
         var actNoInSet = actNo - 1;
        var sceneNoInSet = sceneNo -1;

        $("#playContent").empty();
     
        $("LINE",currentContext).each(function(){

          currentLine = $(this).text(); 
          matchesLine = currentLine.replace(regex_query, '<span class="query_find">' + query + '</span>'); 
          
          if ( currentLine.search(regex_query) > 0 ){
          num_matching_lines++ ;     
              
          $("#playContent").append("<span class='actTitledisplay'>" + $(this).parent().parent().parent().find("TITLE:first").text() + "</span>"); 
          
             $("#playContent").append(" - <span class='sceneTitledisplay'>" + $(this).parent().parent().find("TITLE:first").text() + "</span><br />");	
             
              $("#playContent").append("<p>" + $(this).parent().find("SPEAKER:first").text() + "</p><br />");
             
		  $("#playContent").append("<p>" + matchesLine + "</p>"); 
		
          }  		   
		  	    
        });

        
         var currentWord = 0;
         var currentWordArray = 0;
         var matching_words = 0;
         var total_matching_words = 0;
        
       
        $("LINE",currentContext).each(function(){
		 
		 var query = $("#searchWord").val();
		 
		  
		  currentWord = $(this).text();
		                 
          currentWordArray = currentWord.split(query);  
          matching_words = currentWordArray.length - 1      
          total_matching_words = total_matching_words + matching_words;
		});
		
			$("#sideInfo").empty();	
		$("#playContent").prepend(matching_words);
		

        $("#sideInfo").prepend("<span class='search'><strong>Found <span class='result'>'" + query + "'</span> in " + num_matching_lines + " lines</strong></span><br />");
        
        $("#sideInfo").prepend("<span class='search'><strong> Found <span class='result'>'" + query + "'</span> " + total_matching_words + " times &nbsp; | &nbsp; </strong></span>");
		
        
        $("#playContent").prepend("<button class='AllActs'>To Full Play</button>");

        
 
      }   
         
     $(document).ready(function(){

        $("#searchWord").focus(function(event) {
  	      $(this).val("");
        });

        $("#searchWord").keypress(function(event) {
          if(event.keyCode == 13 ) searchResults($("#searchWord").val());     
        });

        $('#term-search-btn').click(function() {
          searchResults($("#searchWord").val());
        });

      });

uploadw.jpg
 
Back
Top Bottom