Ajax return call for error is not returning : <p>I have an Ajax call inside a function like so:</p>

<pre><code>function send_data(url, data) {
    $.ajax({
        url: url,
        type: 'POST',
        data: data,
        success: function (data) {
            //Empty for now
        },

        error: function (xhr) {
            return xhr.responseJSON;
        },

    });
}
</code></pre>

<p>and then I trigger this function like so:</p>

<pre><code>console.log(send_data(url, data));
</code></pre>

<p>I should receive the response output, but I don't. I instead, get undefined. I know JavaScript is asynchronous, but shouldn't this work? I added a <code>console.log</code> output inside the error function, before the return statement, and it outputs the data correctly. So why doesn't it return the data?</p>
