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

118
Visualizações
Cannot get data to page using Ajax with spring boot

I am not able to get the data on the page using AJAX with Spring Boot. When I try the URL on postman it gets all the values from the database, but when I type the same URL in the browser it's only showing []. I have attached my code here please help me find a solution for this problem. The list of data is taken correctly.

Controller

@RequestMapping(value = "/getEasyQuestionsBySkill/{primarySkill}", method = RequestMethod.GET, produces = { MimeTypeUtils.APPLICATION_JSON_VALUE })
    public ResponseEntity<List<EasyQuestions>> getAllEasyQuestions(@PathVariable String primarySkill) {
        try {

            ResponseEntity<List<EasyQuestions>> responseEntity = new ResponseEntity<List<EasyQuestions>>(easyQuestionsService.getEasyQuestionsBySkill(primarySkill), HttpStatus.OK);
            return responseEntity;
            
        } catch (Exception e) {
            return new ResponseEntity<List<EasyQuestions>> (HttpStatus.BAD_REQUEST);
        }
    }

Thymeleaf - Javascript

$("#skillSubmitBtnId").on("click",function() {
                var skill_name = $(".skillCls").val();
               if(skill_name == ""){
                   
                   alert("Select a Primary Skill");
                   
               }else {
                   
                   $.ajax({
                    type: 'GET',
                    url: '/getEasyQuestionsBySkill/{'+skill_name+'}',
                    dataType: 'json',
                    success: function(result) {
                        var str = '';
                        for(var i=0; i<result.length; i++) {
                            str += '<br/> Question :' +result[i].question;
                            str += '<br/> Primary Skill :' +result[i].primarySkill;
                            str += '<br/> Secondary Skill :' +result[i].secondarySkill;
                            str += '<br/>';
                        }
                        $("#contentDivId").html(str);
                    }
                });
                   
                   $("#errorDivId").hide();
                   $("#javaTableDivId").show(); 
                   
               }
               
            });
about 4 years ago · Santiago Gelvez
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