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

104
Visualizações
jQuery.getScript does not work with jQuery Version 3.x

I'm reloading/re-executing my javascript using jquery's getScript function with

 jQuery('#my-script').empty();
  jQuery.getScript( 'js/myscript.js', function() { 
  });

This worked fine with jquery V1.x or V2.x. Since jquery v3.x the reload works but the re-execute of script fails with error

uncaught SyntaxError: redeclaration of let varname

where "varname" is a class like

class varname {
    constructor(x, y) {
        this.x = x;
        this.y = y;
    }  
  method1 { .. }  
  }

I think the problem is caused by the ES6 Javascript standard. But I could not find a solution to fix my problem other than use the older jquery versions. Has anybody a clue how to solve this?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I've solved the problem - it is caused by ES6 standard, which changes the process of scoping of variables. I had to define my classes as:

var varname = class varname {...}

This solved the issue. Just defining

class varname {...}

will result in a definition of.

let varname = class varname {...}

and this wil cause a failed redeclaration.

about 4 years ago · Juan Pablo Isaza Relatório
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