Calling Ajax and returning response
<p>I have search for so many questions but didnt get the right answer.  I have made the following function from what my research i understand that ajax call is async so on its done passing a value to global variable and returning that but i get a blank or undefined value.i can do it with $('#someid').html in response or some other methods but i dont want to implement them . Any idea what i am doing wrong here</p>

<pre><code>function SimpleAjax(form, postData, url)
{
    var returnData;
    var sendData;

    if (form == "") {
        sendData = postData;
    }
    else if (postData == "") {
        sendData = $(form).serialize();

    }

    $.ajax({
        type: 'POST',
        url: url,
        cache: false,
        data: sendData,
        success: function(data)
        {
            if (data != null || typeof data != 'undefined') {
                returnData = data;
            }
        }
    }).done(function(data) {
        returnData = data;
    });

    return returnData;
}​
</code></pre>
