title: How to create javascript function in custom Wordpress plugin
body: <p>I have create a custom plugin for listing candidate using wp_list_table. Now I have to show all fields information in a popup , on click of href. Below are the step, I am including JavaScript, but it's not working.</p>
  
  <ol>
  <li><p>in my plugin file I included js file as:</p>
  
  <pre><code>include WP_CONTENT_DIR."/plugins/candidate_cv_listing/includes.php";
  </code></pre>
  
  <p>calling my js function like this:</p>
  
  <pre><code>&lt;a href="#"  onclick ="show_details('.$item['id'].');" &gt;Click here &lt;/a&gt;'
  </code></pre></li>
  <li><p>in includes.php following code i had written:</p>
  
  <p>
  
  <pre><code>     if( $hook != 'candidate_cv_listing.php' ) 
      return;
     // core
       wp_enqueue_script('jquery');
     //echo '&lt;script type="text/javascript"     src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"&gt;   &lt;/script&gt;';
  // registering my js file
  wp_register_script('can_list',plugin_dir_url( __FILE__ ).'cand.js');
  wp_enqueue_script('can_list',plugin_dir_url( __FILE__ ).'cand.js');
  }
  add_action('admin_enqueue_scripts', 'candidates_gen_js');
  ?&gt;
  </code></pre></li>
  <li><p>now in cand.js file i am writting my js code as::</p>
  
  <pre><code>function show_details(id){
    //alert(id);
    datastring = 'id='+id;
    $.ajax({
      url: "&lt;?php echo plugins_url();?&gt;/candidate_cv_listing/list_detail.php", 
      type: "POST",
      data: datastring,
      success: function(result){
        $.fancybox(result);
      }
    });
  }
  </code></pre></li>
  </ol>
  
  <p>Please let me know the correct method of including js to plugin, since my plugin will be used in admin-end and how should I make call to my function. Right now its giving me:</p>
  
  <pre><code>ReferenceError: show_details is not defined
  </code></pre>