title: Ajax Copy To Clipboard Not Working (Clipboard.js + Jquery)
body: <p>I have a button. Said button needs to contact the server for a unique URL and put that URL on the user's clipboard. I've tried a bunch of different approaches, but none seem to work. At the moment I'm trying this:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var clipboardItems = new Clipboard('.action_share_file', {
   text: function (trigger) {
    var result = '';
    $.ajax({
     type: "POST",
     async: false,
     url: '/files/change/permissions/' + $('#contextMenu-item').attr('data-id'),
     data: 'permissions=' + JSON.stringify({'read' : 'link'}),
     dataType: "json",
     success: function (msg) {
      //result = msg.url;
                  // for testing purposes.
                  result = 'yay';
     }
    });
  
    return result;
   }
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.5.16/clipboard.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;button class="action_share_file"&gt;Get Share URL&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Unfortunately this doesn't work even though it's synchronous. I'll take any suggestion that allows me to request the URL and put it on the user's clipboard in one go. </p>