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

210
Vistas
Getting unexpected token error when try to script tag dynamically with dynamic script

Goal: Need to create multiple trigger functions dynamically for different id_numbers

I am trying to create a script tag with dynamic code but I am getting below errors

I am getting $window is not defined if I try to write below code

   $(document).ready(function() {
    var script1 = document.createElement('script');
        script1.setAttribute('type','text/javascript');
        
        //script1.text ="$(document).ready(function() {"+
        script1.text = "$window.ATL_JQ_PAGE_PROPS =  {"+
            "'id_number':{"+
                '"triggerFunction": function(showCollectorDialog) {'+
                    'jQuery("#submitBug-id_number").click(function(e) {'+
                        'e.preventDefault();'+
                        'showCollectorDialog();'+
                '   }); '+
            '}'+
        '}'+
            '}';
document.body.appendChild(script1);
});

And I have tried with different method than getting unexpected token '}'

    script1.innerHTML = "$(document).ready(function() {";
    script1.innerHTML = "$window.ATL_JQ_PAGE_PROPS =  {";
        script1.innerHTML = "'id_number' :{";
        script1.innerHTML = "'triggerFunction': function(showCollectorDialog) {";
        script1.innerHTML = "jQuery('#submitBug-id_number').click(function(e) {";
        script1.innerHTML = "e.preventDefault();";
        script1.innerHTML = "showCollectorDialog();";
        script1.innerHTML = "});";
        script1.innerHTML = "},";
        script1.innerHTML = "fieldValues: {";
        script1.innerHTML = "fullname:"+ userName+",";
        script1.innerHTML = "email: "+email+",";
        script1.innerHTML = "recordWebInfo: '1',";
        script1.innerHTML = "recordWebInfoConsent: ['1']";
        script1.innerHTML = "}";
        script1.innerHTML = "}";
        script1.innerHTML = "}";*/
        script1.innerHTML = "});";
document.body.appendChild(script1);

Please help to write a code dynamically under script tag

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