Pass ajax data to another function : <p>I want to apply the <code>getStatus</code> function right here:</p>

<pre><code>function getStatus(id)
{
    $.ajax({
        method: "POST",
        url: '&lt;?php echo base_url('marketplace/get_store_status'); ?&gt;/'+id,
        dataType: 'json',
        success: function(data){
            return data.status;
        }
    });
}
</code></pre>

<p>Into this function right here:</p>

<pre><code>$('#store-status').click(function() {
    var id = getStatus(&lt;?php echo $vendor-&gt;store_id; ?&gt;);
    if (id == 1) {
    $('#btn-status')
        .removeClass('btn-danger')
        .addClass('btn-primary')
        .text('Activate');
    } else {
        $('#btn-status')
        .removeClass('btn-primary')
        .addClass('btn-danger')
        .text('Deactivate');
    }
    console.log(id);
    $('#modal-status').modal('show');
});
</code></pre>

<p>But when i log the <code>id</code> variable in the element click function into the console, it shows <code>undefined</code>. </p>

<p>But when i log the success data from the getStatus function itself, it shows the correct data. What am I doing wrong in my code?</p>
