title: JavaScript, Ajax request on click, does not work, no errors, unable to get uid
body: <p>Can someone help me to understand what is about my javascript that it's not working. It should be giving me uid at the click on link but I get nothing so far. It should show or do something at link but it doesn't do anything nor any error in the console log either. I'll really appreciate some help.</p>
  <p>JS.file</p>
  <pre><code>let pn_uid = function(){
  
  let _has_loaded_uid = false
  let _cached_uid = null
  
  function pn_uid (cb) {
  
      let uid = (tp &amp;&amp; tp.pianoId &amp;&amp; tp.pianoId.getUser()) ? (tp.pianoId.getUser()).uid : null
      if (uid == null) return cb(null)
  
      tp.push([&quot;init&quot;, function() {
          var params = {
              rid : window.pn_bookmark.rid
          };
          var callback = function(response) {
              _has_loaded_uid = true
              if (response.access &amp;&amp; response.access.granted) {
           
                  _cached_uid = uid
                  return cb(uid)
              }
              else {
                  _cached_uid = null
                  return cb(null)
              }
          }
          tp.api.callApi(&quot;/access/check&quot;, params, callback);
      }]);
  }
  
  return {
      check: pn_uid
  }
  
   let pn_bookmark = function(){
  function pn_bookmark_load() {
      pn_uid.check((uid) =&gt; {
          const data = {
              'action': 'pn_bookmark_get',
              '_ajax_nonce': window.pn_bookmark.sec,
              'uid': uid
          };
          jQuery.post(window.pn_bookmark.ajax_url, data, function(response) {
          let element = document.querySelector(&quot;#pn-com-container-bookmark a&quot;);
          console.log(response.bookmarkslist);
          console.log(response.data);
          element.innerHTML = response.bookmarkhtml;
          });
      });
  }
  
  jQuery(document).ready(function($) {
      pn_bookmark_load();
  });
  }()
  </code></pre>
  <p>Controller.php</p>
  <pre><code>       function getBookmarks($user_id) {
      global $wpdb;
  
      $query = $wpdb-&gt;prepare(&quot;SELECT postid FROM bookmarks WHERE user_id='%s' ORDER BY date_created&quot;, $user_id);
      $results = $wpdb-&gt;get_results($query, ARRAY_A);
  
       $response = [];
      foreach ( $results as $result ) {
      $response[] = new UserData($result);       
      }
  
      var_dump($results);
      return $response;
    }
  </code></pre>
  <p>file.php</p>
  <pre><code> &lt;?php
  
    class Bookmarking {
  
  /**
  * @var UserController
  */
  private $userModel;
  
  /**
  * @var CommentController
  */
  private $bookmarkingModel;
  
  public function __construct($bookmarkingModel, $userModel) {
      add_action( 'wp_ajax_pn_bookmark_get', array( $this, 'pn_bookmark_get' ) ); 
      add_action( 'wp_ajax_nopriv_pn_bookmark_get', array( $this, 'pn_bookmark_get' ) );
      add_shortcode( 'display_saved_bookmarks', array($this, 'get_all_bookmarks_shortcode'));
  
      $this-&gt;userModel = $userModel;
      $this-&gt;bookmarkingModel = $bookmarkingModel;
  }
  
       private function bookmarkJS() {
       $nonce = wp_create_nonce('pn_bookmark_get_nonce');
      if (class_exists(&quot;PianoSettings&quot;)) {
          $settings = new \PianoSettings();
          $rid = $settings-&gt;getResource();
      } else {
          $rid = &quot;&quot;;
      }
      wp_enqueue_script('pn_bookmarks',
          plugins_url(&quot;../../www/js/pn_bookmarks.js&quot;, __FILE__)
      );
      wp_localize_script( 
          'pn_bookmarks',
          'pn_bookmarks',
          array(
              'pn_bookmarks' =&gt; admin_url( 'admin-ajax.php' ),
              'sec' =&gt; $nonce,
              'rid' =&gt; $rid ) );
  }
  
  
      public function pn_bookmark_get() {
      check_ajax_referer( 'pn_bookmark_get_nonce', 'nonce' );
     
      if (isset($_POST['uid'])) {
          $piano_user_id = $_POST['uid']; 
  
          $data = [
              'piano_user_id' =&gt; $piano_user_id
          ];
          
         $bookmarkslist = $this-&gt;$bookmarkingModel-&gt;getBookmarksList($piano_user_id);
         $bookmarkhtml = $this-&gt;get_all_bookmarks_shortcode();
  
          wp_send_json([&quot;s&quot; =&gt; true, &quot;data&quot; =&gt; $data, &quot;bookmarkslist&quot; =&gt; $bookmarkslist, &quot;bookmarkhtml&quot; =&gt; $bookmarkhtml]);
      }
  }
  
   public function get_all_bookmarks_shortcode() {
  
      $this-&gt;bookmarkJS();
  
      $bookmarkhtml = &lt;&lt;&lt;HTML
      &lt;div id=&quot;pn-com-container-bookmark&quot;&gt;
      &lt;a href=&quot;#&quot;&gt;View Bookmarks&lt;/a&gt;
      &lt;/div&gt;
      HTML;
  
      return $bookmarkhtml;
  
     }
  
   }
  </code></pre>