Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

178
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda