tags:

views:

34

answers:

1
+1  A: 

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
thanks for you solution. with your code, i added the updateResults(); as the very last line it works!!! thank you very much
@user271785 - welcome!
Nick Craver