Update : I was able to use the callbacks but i really need to get the value returned by the callback. so i did this :
    $( document ).ready(function() {
        console.log(testcall());
    });
    function testcall()
    {
        return result = doXHR(xhrCallback);
    }
    // create a function the returns the result for test.json
    function doXHR(callback)
    {
        $.ajax({
            url : 'test.json',
            success : callback,
        });
    }
    function xhrCallback(result)
    {
        console.log(result);
        return result;
    }
It turns out it will still be undefined.
===========================================================================
I'm in a bit of a problem, I have a function that sends an ajax request. I have seen the other questions regarding this topic, but it seems that the answers doesn't solve my problem.
function callXHR(params)
{
    var req = $.post(params.url, params.data);   
    // process for success
    req.success(function(response){
       // response processing
    });
    // this function needs to return the processed response from
    // my req.success
    return; //<the value processed on the req.success>;
}
I have already studied the concept of deferred objects and promises. The thing is i just don't know how to wait for the ajax call to be resolve before i return the values and end my function.
thank you very much!
cheers!!!
