Hey a better solution is using the async: false property, something like this:
var id = $(this).children().html(); // id is 5
$.ajax({
url: 'ajax.php?id=' + id,
async: false,
success: function(data) {
id = data; // id is 1
}
});
if(id == 1){ // id is again 5
...
}