I'm having a difficult time with my script, i'm newer to js also. The problem i'm having is the script will execute once just fine, however if you attempt to start the search over, it hangs.
Code:$(document).ready(function(){ $('#keyword').bind('keyup',function(){ var keyword = $('#keyword').val(); var limit = $('#limit').val(); if(keyword.length>3){ searchKeyword(); } else if(keyword.length==0){ $('#searchResult').html(''); searchTerm=''; } }); $('#search').click(searchKeyword); }); var searchKeyword = function(){ var resultDiv =$('#searchResult'); var searchTerm = $('#keyword').val(); var resultLimit = $('#limit').val(); resultDiv.html('<img src="/img/loading.gif">'); $.getJSON('/json/reports/master_report_search.php?limit='+resultLimit+'&keyword='+searchTerm,function(data){ resultDiv.html(''); resultDiv.append(data.length+' results for "'+searchTerm+'"'); //filter through results for (var i=0; i<data.length; i++){ var row = '<div><a href="/reports/master/view.php?id='+data[i].id+'"> '+data[i].name + ' '+ data[i].date+'</a></div>'; resultDiv.append(row); } }); }



Reply With Quote

Bookmarks