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

200
Visualizações
Calling java method in Javascript loop function

I am running a javascript function which is under a for loop. The called javascript function calls a java method with the passed parameters. I don't know why java method not execute each time javascript function in loop is called. But it executes after loop has completed. So, called java method doesn't follow the order of passed parameter. The sample code of my program will look like this:

function firstfunction() {
    var x = 5;
    for (var j = 0; j < 5; j++) {
        secondfunction(j, x);
    }
}

function secondfunction(j, x) {
    JavaClass.Javamethod(j, x, callback);
}

Java method do some calculation and return some value as callback. I want my code to call the java method and return the value and then go in javascript loop to take the next parameter and so on.

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

0

You can not directly call the Java method/function once JavaScript code is executed, to execute that you have to use JavaScript ajax function which is used to execute backend programming language function for eg. Java method based on the url you defined of that method and passed the parameters in the ajax 'data' which is required by the java method and in ajax response you will get the return value of that java method.

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