title: Wordpress ajax cannot get it to work always returns 0
body: <p>I've tried to get an ajax function to work with wordpress and always get the default result.
  I have in functions.php (beside other functions)</p>
  
  <pre><code>add_action('wp_ajax_count_results_cal', 'count_results');
  add_action('wp_ajax_nopriv_count_results_cal', 'count_results');
  
  function count_results(){
        echo 'test';
        die();
  }
  
  function my_theme_scripts() {
    wp_enqueue_script( 'jquery' );
    wp_enqueue_script( 'theme-plugins',get_template_directory_uri() . '/js/plugins.js' ,             array( 'jquery','jquery-ui-draggable','jquery-ui-dialog' ) );
    wp_enqueue_script( 'google-map','http://maps.google.com/maps/api/js?sensor=true',     array( 'jquery','jquery-ui-draggable','jquery-ui-dialog' ) );
    wp_enqueue_script( 'theme-script', get_template_directory_uri() . '/js/script.js', array( 'jquery','jquery-ui-draggable','jquery-ui-dialog' ) );
    wp_enqueue_script( 'ajax', get_template_directory_uri() . '/js/ajax.js', array( 'jquery') );
  
  }    
  
  add_action('init', 'my_theme_scripts');
  </code></pre>
  
  <p>And in my ajax.js file</p>
  
  <pre><code>jQuery(document).ready(function ($) {
  
  $('#manufacturer,#make_date,#fuel_type,#transmission,#price_from,#price_to').on({
      change: function(){
  
          $.ajax({
              type: 'POST',
              url: '/wp-admin/admin-ajax.php',
          data: {
              action: 'count_results_cal',
              manufacturer : $("#manufacturer").val(),
              year : $("#make_date").val(),
              fuel : $("#fuel_type").val(),
              transmission : $("#transmission").val(),
              price_from: $("#price_from").val(),
              price_to : $("#price_to").val(),
              body_type : $("#body_type").val(),
              vat : $("#vat").val()
          },
          success: function(data, textStatus, XMLHttpRequest){
              $('#offers_found span').html(data);
          },
          error: function(MLHttpRequest, textStatus, errorThrown){
              alert(errorThrown);
          }
          });
  }});
  </code></pre>
  
  <p>});
  I've tried everything I could think of with no results. Does anyone have some ideas?</p>