title: How to call ajax in Wordpress
body: <p>My ajax call output is always showing 0 as output don't know why</p>
  
  <p>In <code>functions.php</code> I have this code </p>
  
  <pre><code>function get_data() {
      $abc = '1';
      $result = $wpdb-&gt;get_results("SELECT * FROM ".$wpdb-&gt;options ." WHERE option_name LIKE '_transient_%'");
      echo  $result; //returning this value but still shows 0
      wp_die();
  }
  
  add_action( 'wp_ajax_nopriv_get_data', 'get_data' );
  add_action( 'wp_ajax_get_data', 'get_data' );
  </code></pre>
  
  <p>And my ajax call is in a javascript </p>
  
  <pre><code>$('body').on("click", ".re-reset-btn", function(e){
  
      var panel = $('#re-compare-bar');       
  
      $.ajax({
               type : "GET",
               dataType : "json",
               url : "/wp-admin/admin-ajax.php",
               data : {action: "get_data"},
               success: function(response) {
  
                     alert("Your vote could not be added");
                     alert(response);
                  }
          });   
  
      $("#re-compare-bar-tabs div").remove(); 
      $('.re-compare-icon-toggle .re-compare-notice').text(0); 
  
  });
  </code></pre>
  
  <p>I'm making ajax call in wordpress without use of plugin but not getting what I'm passing.Even If I output $abc still it shows 0.</p>