I send an ajax request with jquery like this:
$.post("ajax/myFile.php", {
myValue: "test"
}, function(response) {
console.log($.parseJSON(response))
})
content of myFile.php
myFunctionA();
myFunctionB();
function myFunctionA() {
echo json_encode(array('error' => 0, 'message' => "Hello World"));
}
function myFunctionB() {
echo json_encode(array('error' => 0, 'message' => "Hello again"));
}
my console.log result:
Uncaught SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data at line 1 column 44 of the JSON data
how can I handle this? :/
echos are each outputting their own JSON, not a cohesive JSON response, so basically 2 JSON back to back, which isn't a valid JSON response.