PHP Return JSON object to Javascript [AJAX CALL] not working
<p>I have made Ajax calls before, and let them return JSON objects, which worked, but I dont seem to get it working anymore. </p>

<p>This is my ajax call:</p>

<pre><code>function sendContactForm() {
var nameInput = $('#nameInput').val();
var emailInput = $('#emailInput').val();
var subjectInput = $('#subjectInput').val();
var msgInput = $('#msgInput').val();

$.ajax({
    // Make a POST request to getfile       
    url: "/service/contactmail",
    data: {
        nameInput: nameInput,
        emailInput: emailInput,
        subjectInput: subjectInput,
        msgInput: msgInput
    },
    method: "post",
    // And run this on success      
    success: function (data) {
        if (data.send === 1){
            // VERZONDEN
        }else if(data.send === 2){
            // VARS NIET INGEVULT
        }else{
            // IETS ANDERS FOUT
        }
        console.log(data);
    },
    error: function () {
        alert("fout");
    }
});
}
</code></pre>

<p>and this is my php function:</p>

<pre><code>private function sendContactForm() {
    $output = array(
        "test" =&gt; null,
        "send" =&gt; null
    );
    if ($this-&gt;fillVariables()) {
        $this-&gt;sendMail();
        $output['send'] = 1;
        return true;
    } else {
        $output['send'] = 2;
        return false;
    }
    header("Content-Type: application/json");
    echo json_encode($output);
}
</code></pre>

<p>but the variable "data" has a value of: "" (empty string)
There are no other echo's in my php class, so that should not be the problem.</p>

<p>Thanks in advance,<br>
Mats de Waard</p>