If you would like to implement asynchronous calls, then you want to organize all logic that is to be done with the resultant data into the .succcess() callback.
the reason that async is false is because when i fire the success callback the xml data isn't loaded but when I load a completed callback everything loads fine.
That line from your question is a bit confusing because the by definition, the success callback is executed once the request completed and any data returned is available.
This is an example of what you cannot do with async: true:
function ajaxrequest() {
var someValue;
$.get('serverFile.php', function(data){
someValue = data;
});
return someValue;
}
In that case, the variable someValue will be empty when it is returned because the callback you supplied isn't executed synchronously, or in-line, with the rest of your code.
To use async:true you can organize your code like this:
function getData() {
return $.get('serverFile.php');
}
function alertData() {
getData().done(function(data){
alert(data);
});
}
function logData() {
getData().done(function(data){
console.log(data);
});
}
I have broken it up this way so you can see that it can be helpful to isolate your request methods and have them return the jQuery Deferred object so that multiple other functions can utilize the same request if needed.