$ .ajax发布到php脚本间歇性地工作

I am trying to send to variable to a php script that will send out an email. It works about 75% of the time. I think I've narrowed it down to the variable just not getting to the php page sometimes but I don't know why. Below is my code:

///////////////////////Javascript/////////////////////////

function postData(randomstring) {
var eml = $("#txtEmail").val();
$.ajax({
    type: "POST",
    url: "/api/v1/fp_eml/",
    dataType: "json",
    async: false,
    data: JSON.stringify({ email: eml, password: randomstring }),
    contentType: "application/json; charset=utf-8",
    complete: function () {
        alert("Password reset, email sent.");
        window.location.href = "/";
    },
    error: function (err) {
        console.log(err);
    }
});
}

///////////////////////PHP/////////////////////////

// process client request (Via URL)
header("Content-Type:application/json");

include("../../../api/aws/aws-functions.php");

// Get POST data
$request_body = file_get_contents("php://input");
$json = json_decode($request_body, true);
$data = array($json);

$email=$data[0]['email'];
$password=$data[0]['password'];

error_log($email);

$account=get_account($email);

if(empty($account))
    echo "Something went wrong";
else
    // send email to customer with password
    $to = $email;
    $subject = "Forgot Password";
    $txt = "Your password has been reset to: " . $password . "
" . "Please log in immediately and reset your password." . "
" . "If you did not request your password to be reset, please contact us immediately.";
    $headers = "From: test@email.com";

    $sent = mail($to,$subject,$txt,$headers);

///////////////////////Error Log/////////////////////////

[11-Nov-2016 17:50:20 UTC] test@email.com
[11-Nov-2016 17:52:54 UTC] test@email.com
[11-Nov-2016 17:53:20 UTC]
[11-Nov-2016 17:53:20 UTC] PHP Fatal error:  Uncaught exception
Aws\DynamoDb\Exception\DynamoDbException' with message 'Error executing
"Query" on "https://dynamodb.us-west-2.amazonaws.com"; AWS HTTP error: 
Client error: `POST https://dynamodb.us-west-2.amazonaws.com` resulted in a 
`400 Bad Request` response
{"__type":"com.amazon.coral.service#SerializationException","Message":"Start 
of list found where not expected"} SerializationException (client): Start of 
list found where not expected - 
{"__type":"com.amazon.coral.service#SerializationException","Message":"Start 
of list found where not expected"}'
exception 'GuzzleHttp\Exception\ClientException' with message 'Client error: 
`POST https://dynamodb.us-west-2.amazonaws.com` resulted in a `400 Bad 
Request` response:
{"__type":"com.amazon.coral.service#SerializationException","Message":"Start of list found where not expected"}
' in  home/mjohn1404/public_html/api/aws/GuzzleHttp/Exception/RequestException.php:107 Stack trace:#0 home/mjohn1404/public_html/api/aws/GuzzleHttp/Middleware.php(65): GuzzleH in home/mjohn1404/public_html/api/aws/Aws/WrappedHttpHandler.php on line 159

As you can see the tests at 17:50 and 17:52 worked just fine however the test at 17:53 failed. The email address wasn't recognized so the DB query failed. Any assistance in the right direction would be greatly appreciated. Thank you all for your time.