title: document execCommand copy not working with AJAX
body: <p>I can't copy the generated link directly (without ctrl+C)
  I am usign <code>document.execCommand('copy')</code> but it seems it has no effect.
  <strong>If code has no AJAX then its working pefectly</strong>.
  Here's the </p>
  
  <ul>
  <li><p><a href="https://jsfiddle.net/pbL7abd3/2/" rel="nofollow noreferrer">fiddle link with AJAX</a></p></li>
  <li><p><a href="https://jsfiddle.net/pbL7abd3/3/" rel="nofollow noreferrer">fiddle link without AJAX</a></p></li>
  </ul>
  
  <p><strong>HTML</strong>:</p>
  
  <pre><code>&lt;div class="permalink-control"&gt; &lt;/div&gt;
  </code></pre>
  
  <p><strong>JQUERY</strong>:   </p>
  
  <pre><code>    $(".permalink-control")
            .append(
              '&lt;div class="input-group"&gt;' +
              '    &lt;span class="input-group-btn"&gt;&lt;button type="button" class="btn btn-default" title="Get Permalink"&gt;&lt;span class="glyphicon glyphicon-link"&gt;&lt;/span&gt;&lt;/button&gt;&lt;/span&gt;' +
              '    &lt;input type="text" class="form-control"&gt;' +
              '&lt;/div&gt;'
            );
          $(".permalink-control input")
            .hide()
            .focus(function () {
              // Workaround for broken selection: https://stackoverflow.com/questions/5797539
              var $this = $(this);
              $this.select()
                .mouseup(function () {
                  $this.unbind("mouseup");
                  return false;
                });
            });
          $(".permalink-control button")
            .click(function () {
              var $this = $(this);
              $.ajax({
                url: "https://api-ssl.bitly.com/shorten",
                dataType: "jsonp",
                data: {
                  longUrl: window.location.href,
                  access_token: "your access token",
                  format: "json"
                },
                success: function (response) {
                  var longUrl = Object.keys(response.results)[0];
                  var shortUrl = response.results[longUrl].shortUrl;
                  if (shortUrl.indexOf(":") === 4) {
                    shortUrl = "https" + shortUrl.substring(4);
                  }
                  $this.parents(".permalink-control")
                    .find("input")
                    .show()
                    .val(shortUrl)
                    .focus();
                },
                async:false
              });
            });
  </code></pre>
  
  <p><strong>UPDATE:</strong></p>
  
  <p><a href="https://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript">How do I copy to the clipboard in JavaScript?</a></p>
  
  <p>is not answer to my question as My code also copies without using ctrl+C if AJAX is not there.
  However when I am using AJAX <code>document.execCommand('copy')</code> is not working.</p>