title: calling jQuery Ajax function fom page onload or script tag
body: <p>I'm working on an AJAX filter for a custom post type in Wordpress. It's working perfectly fine however I have one thing that I can't get to work. I want to execute the AJAX function from a script tag in the body (or from body onload if that works better), this way I can tell the function which filters to turn on when loading the page. </p>
  
  <p>This is function to load the AJAX </p>
  
  <pre><code>// ajaxLoop.js
  jQuery(function($){
  
  var loading = true;
  var $window = $(window);
  var $content = $("body #filterAanbod");
  
  // ajax inladen, afhankelijk van categorie, onderwijs type en kerndoel. 
  function loadActiviteiten(cat, type, doel, populair){
              $.ajax({
                  type       : "GET",
                  data       : {categorie : cat, type : type, kerndoel : doel, pop: populair},
                  dataType   : "html",
                  url        : "loopHandler.php",
                  beforeSend : function() {
                            $content.fadeOut(100);
                            $content.append(
                              '&lt;img src="images/ajax-loader.gif" /&gt;'
                            );  
  
                     } 
                  })
                .done(function(data) {
                          $content.hide();
                          $content.html(data);
                          $content.fadeIn(500, function() { 
                                  loading = false;
                                    $("#temp_load").remove();
                                  });
                          })
                .fail(function() {   $("#temp_load").remove(); alert("failed miserably"); });
  
  
      }
  </code></pre>
  
  <p>I used a jQuery click function to execute <code>loadActiviteiten(cat, type, doel, populair)</code> for the filter navigation. And that works perfectly fine. However when I want to execute it in the template file, it doesn't do anything. </p>
  
  <p>This is all i did in template.php</p>
  
  <pre><code>&lt;script type="text/javacsript"&gt;
  $(function() {
    loadActiviteiten();
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>The idea is to make a custom meta box, where the user can select which filters to turn on current page and that converts to the javascript function ex. <code>loadActiviteiten(term-slug,0,0,0);</code> just loading posts that match the 'term-slug' of the taxonomy 'categorie'.</p>
  
  <p>I really don't understand why it's not executing, can anyone help me?</p>
  
  <p>oo fyi, i'm not getting any errors in my console. </p>
  
  <p>Thanks. </p>