Question: ```
   function ajaxRefresh(actionUrl) {
        $.ajax({
        url: actionUrl,
        success: function() {
             return true;
        }});
        return false;
    }

```

The function anyway returns `false` even when a request is succeeded, becouse the request is asynchronous. How I can return `true` when request is succeeded?

Answer: 
You can't return "true" until the ajax requests has not finished because it's asynchron as you mentioned. So the function is leaved before the ajax request has finished.

Solution 1
----------

```
function ajaxRefresh(actionUrl, successCallback) {
    $.ajax({
       url: actionUrl,
       success: successcallback
    });
}

```

But there's a workaround: Just add a callback parameter to the function. This function will be executed when the request has finished.

Solution 2
----------

You can return a jquery deferred. 

```
function ajaxRefresh(actionUrl, successCallback) {
    return $.ajax({
       url: actionUrl
    });
}

```

Now you can use the function like:

```
function otherFunction()
{
     ajaxRefresh().success(function() {
        //The ajax refresh succeeded!
     }).error(function() {
        //There was an error!
     });
}

```

For more information about jquery deferreds look at <http://www.erichynds.com/jquery/using-deferreds-in-jquery/>.
```
function ajaxRefresh(actionUrl) {   
    bool isSucesss=false;
    $.ajax({       
        url: actionUrl,        
        success: function() {   
            isSucesss=true;     
        },
        error:function() {   
            isSucesss= false;     
        }
    });     
    return isSucesss;
}

```