I have the following method in my PHP class that processes messages and sends it back to JQuery. It works fine if there is only a single message to send back but if there is more than one, it sends them back as separate json objects. The messages are sent back ok but JQuery gives me an error. The messages look like this:
{"error":true,"msg":"Message 1 here..."}{"error":true,"msg":"Message 2 here"}
My PHP method looks like this:
private function responseMessage($bool, $msg) {
$return['error'] = $bool;
$return['msg'] = $msg;
if (isset($_POST['plAjax']) && $_POST['plAjax'] == true) {
echo json_encode($return);
}
...
}
I don't know how to change this so multiple error messages are put into a single json encoded message but also work if it is just a single message.
Can you help? Thanks