title: How do I fix the :ERR_BLOCKED_BY_CLIENT Error with Youtube Data Api V3 when displaying youtube videos using Iframe on the DOM?
body: <p>I'm testing the Youtube Data API V3 to get a list videos by a query term and subsequently play them in an iframe. </p>
  
  <p>I'm getting this error: 
  <code>www-embed-player.js:306 GET https://googleads.g.doubleclick.net/pagead/id?exp=nomnom net::ERR_BLOCKED_BY_CLIENT</code></p>
  
  <p>After some debugging and googling, I discovered that this error is often caused by  adblockers. I've then disabled mine on Chrome and then retested the api call.
  I no longer see the original error <code>:ERR_BLOCKED_BY_CLIENT</code> but my videos retrieved do not play. Player message: <code>An error occurred, please try again later.</code></p>
  
  <p>Below is the code. The JS is in the HTML file itself for simplicity.</p>
  
  <p>Any help appreciated!</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html lang="en"&gt;
  
  &lt;head&gt;
      &lt;title&gt;Youtube API Test &lt;/title&gt;
      &lt;!-- Required meta tags --&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"&gt;
  
      &lt;!-- Bootstrap CSS --&gt;
      &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb"
          crossorigin="anonymous"&gt;
  &lt;/head&gt;
  &lt;style&gt;
      body {
          background-color: #0F0F0F;
      }
  
      button.btn.btn-primary {
          background-color: #E12523;
          border-color: #E12523;
      }
  
      div.jumbotron {
          background-color: #292929;
          color: #B3B3B3;
      }
  
      hr.my-2 {
          border: 1px solid #B3B3B3;
      }
  &lt;/style&gt;
  
  &lt;body&gt;
  
  
  
  
  
  
      &lt;div class="wrapper container"&gt;
          &lt;div class="jumbotron"&gt;
              &lt;h1 class="display-3"&gt;Youtube Api&lt;/h1&gt;
              &lt;p class="lead"&gt;Let's use the Yotube Api to get videos&lt;/p&gt;
              &lt;hr class="my-2"&gt;
  
              &lt;form&gt;
                  &lt;div class="form-group"&gt;
                      &lt;label for="user-query"&gt;&lt;/label&gt;
                      &lt;input type="text" class="form-control" id="user-query" aria-describedby="emailHelp" placeholder="Search Youtube"&gt;
                  &lt;/div&gt;
                  &lt;button type="submit" class="btn btn-primary" id="submit"&gt;Submit&lt;/button&gt;
              &lt;/form&gt;
  
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class="container" id="results"&gt;&lt;/div&gt;
  
  
  
  
  
  
      &lt;!-- jQuery first, then Popper.js, then Bootstrap JS --&gt;
      &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh"
          crossorigin="anonymous"&gt;&lt;/script&gt;
      &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ"
          crossorigin="anonymous"&gt;&lt;/script&gt;
  
      &lt;script type="text/javascript"&gt;
  
  
          //Get Videos
          $("#submit").on("click", function (event) {
              event.preventDefault();
              var queryTerm = $("#user-query").val().trim();
  
              $.ajax({
                  url: "https://www.googleapis.com/youtube/v3/search?part=snippet&amp;q=" + queryTerm + "&amp;type=video&amp;key=[MY API KEY]",
                  method: "GET"
              }).then(function (data) {
                  console.log(data);
                  $.each(data.items, (i, item) =&gt; {
                      console.log(data.item);
                      const videoId = item.id.videoId;
                      let $iFrameContainer = $(`&lt;iframe width="420" height="345" src="https://www.youtube.com/embed/"' ${videoId} '&gt; &lt;\/iframe &gt;`);
  
                      $("#results").append($iFrameContainer);
                      })
                  });
              })
  
      &lt;/script&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>