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

110
Views
ajax response returns every value as a single character

I am trying to figure out where I go wrong in this request. I have an ajax post request and I receive the response as single character. For example instead of "name":"john" I get:
n
a
m
e
j
o
h
n
This is my code:

    $.ajax({
        url: 'test.php',
        type: "POST",
        data: ({
            name: 'john'
        }),
        success: function(data) {
            var JSONString = data;
            var JSONObject = JSON.parse(JSONString);
            console.log(JSONString);
            load(JSONString);
        },
        error: function() {
            alert('error');
        }
    });
}

<?php
$db = new SQLite3('database.db');
$userAnswer = $_POST['name']; 

$results= $db->query("SELECT * FROM 'database' where name='".$userAnswer."'");

$data= [];
while ($res= $results->fetchArray(1))
{
array_push($data, $res);
}
echo json_encode($data);

?>
function load(res) {
    var JSONObject = res;
    var arr = Object.values(JSONObject);
    for (var i = 0; i < arr.length; i++) {
        }
    }
}
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!