testing result of $.post with json_encode

If you want to check the value of your JSON response in JS, you need to parse the JSON object you’re returning before trying to access any values:

jsonResponse = JSON.parse(response);
if (jsonResponse.success === true) { /*do something*/ }