Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

177
Visualizações
Inject script programatically results in error 500 (LinkedIn follower plugin)

I want to insert the LinkedIn Follow Company Plugin, but only inject it, if the user has given consent. So instead of putting in the script tags directly, I have a banner, asking for consent and if the checkbox is checked the following function runs:

function injectLinkedin() {
  var linkedin_container = document.querySelector('#linkedin-follow-plugin');

  var script = document.createElement("script");
  script.setAttribute("src", "https://platform.linkedin.com/in.js");
  script.setAttribute("type", "text/javascript");
  script.setAttribute("async", "false");
  script.textContent = 'lang: de_DE';
  script.onload = function(){
      console.log('li');
  };
  linkedin_container.appendChild(script);

  var script2 = document.createElement("script");
  script2.type = "IN/FollowCompany";
  script2.setAttribute('data-id' , '1234');
  script2.setAttribute('data-counter' , 'bottom');
  script2.onload = function(){
    console.log('li2');
  };
  linkedin_container.appendChild(script2);
}

But that way LinkedIn responds with an error 500 for https://platform.linkedin.com/in.js

Don't see why/how linkedin can see how the code gets loaded. Putting in the script tags directly it works fine. And, strangely, this error is not on my local machine but only on the live server.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda