title: When is the DOM ready after a jQuery ajax call?
body: <p>I have a ASP.NET MVC3 project making an ajax call that returns HTML that I can successfully inject into the page. However I have a problem in hiding a CSS class after the code has been injected.  I suspect that the DOM is not ready.</p>
  
  <p>I am aware that the document ready function <em>$(function () {...}</em> is only called when the page is loaded initially - and I don't want to call it again anyway - so I was wondering if there is another method that can be used after an ajax call to determine when the DOM is ready. </p>
  
  <p>This is the ajax code:</p>
  
  <pre><code>    $.ajax(
              {
                  url: '/seoreports/seoupdate',
                  type: "post",
                  dataType: "html",
                  data: JSON.stringify(dt),
                  contentType: "application/json; charset=utf-8",
                  success: function (result) {
                      $('#seolist').html(result);
                      if (ptshow == false) { $('.seo-pt').hide(); }
                  }
              });
  </code></pre>
  
  <p>The idea is that if the <em>ptshow</em> variable is false it hides all the divs with the class <em>seo-pt</em> after the HTML has been injected.</p>
  
  <p>I did try, just for testing, to put <em>alert('hello world');</em> in the success function, but that didn't work so maybe there is something I'm not understanding about the success function.</p>