Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

307
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!