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 refactor your code a little bit so that your success callback triggers the next operation that depends on the true/false result. For example, if you currently have something like:

```
function main() {
  // some code

  if (ajaxRefresh(url)) {
    // do something
  }
}

```

You would change that to something like:

```
function main() {
  // some code

  ajaxRefresh(url);
}

function doSomething(successFlag) {
  if (successFlag) {
    // do something
  }
}

function ajaxRefresh(actionUrl) {
  $.ajax({
         url: actionUrl,
         success: function() {
           doSomething(true); // or false as appropriate
         }});
}

```

You could also put the `if` test into the ajax callback function instead of in the `doSomething()` function. Up to you.

Or you can make a synchronous request, and figure out the `ajaxRefresh()` function's return value after the request is done. I would not recommend that for most purposes.
```
function ajaxRefresh(actionUrl) {   
    bool isSucesss=false;
    $.ajax({       
        url: actionUrl,        
        success: function() {   
            isSucesss=true;     
        },
        error:function() {   
            isSucesss= false;     
        }
    });     
    return isSucesss;
}

```