I always receive the Parser error in pushJsonData and I don't know why.
I tested it first with just the user value and it works fine, but when I try to thrwo back mor than the user I recieve the error below:
SyntaxError: Unexpected end of JSON input [object Object]
My JavaScript code:
$('#Login').click(function() {
var user = $("#user").val();
$.ajax({
url: "src/ajax.php",
type: "POST",
data: { ACTION : "checkUser", USER: user},
dataType: "json",
success: function(data) {
var user = data.user;
$('#testUser').text("Hallo " + user);
},
error: function(jqXHR, textStatus, errorThrown) {
alert(textStatus + " in pushJsonData: " + errorThrown + " " + jqXHR);
}
});
});
My PHP code:
if($_POST['ACTION'] == "checkUser") {
$checkUser = $_POST['USER'];
$sql = $db->query("SELECT * FROM fm_user WHERE user = '".$checkUser."' LIMIT 1");
$getUser = $sql->fetch_assoc();
$resultArray = array(
"user" => $getUser['user'],
"isadmin" => $getUser['isadmin'],
"user_data" => $getUser['user_data']
);
$result = json_encode($resultArray);
}