Currently you're creating an infinite loop (or would be), instead schedule the check inside your success
callback, like this:
function updateResults() {
$.ajax({
type: 'GET',
url: "/sResultsView",
cache: true,
success: function(html){
$("#resultsDiv").html(html);
if($('#resultsDiv p').length == 0) //if not found, run again in 4 seconds
window.setTimeout(updateResults, 4000);
}
});
}
For completeness sake, your syntax error is in the if
statement missing patenthesis, here:
if($('#resultsDiv:not(:has(p))')){
^ ------- missing --------- ^
Nick Craver
2010-10-05 11:50:50