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

316
Visualizações
Ajax: obtain input text using get function from a web api

I have a problem using ajax,

I have a controller get who gives me a simple object (in my case is just one name) but I have this error ( SyntaxError: Unexpected end of JSON input ) and I don't know why.

This is the code:

$(function a() {
    var $hello = $('#hello'); //Here #hello is a id which is inside a div
    $.ajax({
        url: uri_3,
        type: 'GET',
        dataType: 'json', // if i put text here also don't work, gives sucess but don't appear the 
                          //name

        success: function (data) { //have a problem get the name , also I try just $hello.append 
                                   //alone and using h2 rather than li but don't work
            $.each(data, function c(i, name) {
                $hello.append('<li>Name: ' + name + '</li>');
            });
        },

        error: function (xhr, textStatus, errorThrown) { //it always gives me this error, it 
                                                         //doesn't reach the top success 
            console.log('Error in Operation');
            $hello.append('<h4> User Not Found: ' + errorThrown + '</h4>');
        }
    });
});

Since the backend function is working (I tested it using swagger and it gives me the right name), I assume the error must be in this ajax function. What more do I have to add?

Any answer is welcome

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