title: Ajax call in wordpress using action hooks
body: <p>I'm new to wordpress and i wanted to try using ajax calls for some mouse click events. 
  I have some basic code to test if it works.
  In my plugin file plugin.php </p>
  
  <pre><code>function my_scripts() {
    $plugin_url = plugin_dir_url( __FILE__ );
    wp_register_script('search-filter',$plugin_url .  'js/search-filter.js',array(), filemtime( plugin_dir_path( __FILE__ ) .  'js/search-filter.js' ));
    wp_localize_script( 'search-filter', 'my_ajax_call', array( 'ajax_url' =&gt; admin_url('admin-ajax.php')) );
    wp_enqueue_script( 'search-filter');
  }
  add_action( 'wp_enqueue_scripts', 'my_scripts' );
  function myAjaxHanlder(){
    var_dump("THIS IS A TEST");
    echo '&lt;script&gt;console.log("MY AJAX HANDLER")&lt;/script&gt;';
  }
  add_action('wp_ajax_hello_world', 'myAjaxHanlder' );
  add_action('wp_ajax_nopriv_hello_world', 'myAjaxHanlder' );
  </code></pre>
  
  <p>and in my javascript file search-filter.js</p>
  
  <pre><code>(function($){
  
  $(document).ready(function(){
      $(".search-hits").click(function(e){
          e.preventDefault();
          // var gender = $("#gender").val()||[];
          // var brand =$("#brand").val() || [];
          // var color =$("#color").val() || [];
          // var gender_JSON = JSON.stringify(gender);
          $.ajax({
              type: 'POST',
              dataType: 'json',
              crossDomain : true,
              url: my_ajax_call.ajax_url,
              data: {action:'hello_world', query:"nike"},
              success: function(response){
                  alert(response);
              }
  
              });
         });
     });
  
  })(jQuery);
  </code></pre>
  
  <p>I'm able to send the data using ajax, but the function myAjaxHanlder is not getting executed.</p>