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

309
Vistas
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 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