title: AJAX in WP Plugin returns 0 always
body: <p>I'm trying to implement WP AJAX in one of my <a href="https://github.com/nanodesigns/ad-zonia/blob/master/ad-view-page.php" rel="nofollow">Under-dev Plugin</a> after successful implementation in WP Theme.</p>
  
  <pre><code>function deactivate_ad() {
  
      if( isset( $_POST['id'] ) ) {
          echo $_POST['id'];
          echo 'Deactivated';
          die;
      } else {
          echo 'Sorry, not done';
          die;
      }
      wp_die(); // ajax call must die to avoid trailing 0 in your response
  }
  
  add_action('wp_ajax_deactivate_ad', 'deactivate_ad');
  //add_action( 'wp_ajax_nopriv_deactivate_ad', 'deactivate_ad'); //not logged in users
  </code></pre>
  
  <p>And beneath the function somewhere, I added my form with dynamic ID:</p>
  
  <pre><code>&lt;form action="" enctype="multipart/form-data" method="post"&gt;
            &lt;script type="text/javascript"&gt;
            var ajaxurl = '&lt;?php echo admin_url('admin-ajax.php'); ?&gt;';
  
            jQuery(document).on('click', '.deactivate-ad', function () {
                var id = this.id;
                alert(id);
                jQuery.ajax({
                    type: 'POST',
                    url: ajaxurl,
                    data: {
                      "action": "deactivate_ad",
                      "id": id
                    },
                    success: function (data) {
                      alert(data);
                    }
                });
            });
          &lt;/script&gt;
  &lt;?php
          //after the db Query, within the foreach loop
          foreach( $ad_query as $the_ad ){
              $element_id = 'deactivate_' . $the_ad-&gt;id . '_' . wp_create_nonce('deactivate_' . $the_ad-&gt;id );
              // I'm just checking with the 'Deactivate' button first
              echo ( $the_ad-&gt;ad_status == 1 ? '&lt;a class="deactivate-ad" href="#" id="'. $element_id .'"&gt;Deactivate&lt;/a&gt;' : '&lt;a href="?page=site-ad&amp;id='. $the_ad-&gt;id .'&amp;activate=true&amp;success=true"&gt;Activate&lt;/a&gt;' );
          }
  ?&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I'm just trying to activate the AJAX so that I can do whatever I want then. But with first <code>alert(id)</code> I can alert the <code>id</code> with nonce successfully, but the <code>alert(data)</code> it's always returning <code>0</code> (zero).</p>
  
  <p>I am enqueueing  the latest jQuery (<a href="http://code.jquery.com/jquery-latest.min.js" rel="nofollow">http://code.jquery.com/jquery-latest.min.js</a>) at the beginning and checked all the instances. What am I doing wrong this time - the process I acquired worked in a theme - I worked earlier.</p>