title: Not getting wordpress nonce to work with wp-rest api application
body: <p>I have an app which is should be secure and therefore using Nonce's but I can't get them to work.
  I have tried several options but apparently something is missing as the validation doesn't work.</p>
  
  <p>My js code fragment is:</p>
  
  <pre><code>function placeNew(next){
    _nonce = $('input#_nonce').val();
    request = $.ajax({
      type: 'POST',
      url: url_path + '/foo/v1/newbee',
      data: {bid : next , _nonce : _nonce},
      security: '&lt;?php echo wp_create_nonce( "a" ); ?&gt;',
      dataType: 'json'
  });
  request.done(function (response, textStatus, jqXHR){
    str = JSON.stringify(response);
    if(response["error"]){
      alert(response["message"]);
    }
  </code></pre>
  
  <p>The nonce is added to the page with the following code:</p>
  
  <pre><code>$nonce = wp_create_nonce( 'a' );
  echo "&lt;input type='hidden' id='_nonce' value=" . $nonce ."/&gt;";
  </code></pre>
  
  <p>Within php the following function fragment is used to get and compare the nonce:</p>
  
  <pre><code>function ace($request) {
      global $wpdb;
      $timestamp = time();
      $nonce = (string) $request['_nonce'];
      $verify = check_ajax_referer( 'a', $nonce, false );
      if ( ! $verify){
          $errMsg = $nonce . '-'. $verify .' not validated ';
          return (object) array(error =&gt; true, message =&gt; $errMsg);
      }
  </code></pre>
  
  <p>I always do get the message "not validated". $nonce has a value but $verify never gets a value.</p>