Since AJAX is asynchronous, you can't, because your AJAX call will not return immediately. What you can do instead, what people usually do, is take a callback function and then call that with the return value. For example:
function something(callback) {
var id = 0;
$.ajax({
'url':'/some/url',
'type':'GET',
'data':{'some':'data'},
'success':function(data){
callback(data['id']);
}
});
}
something(function(id) {
alert(id);
});
Note that you could always make your request synchronous and it would wait until it has data and you could return it immediately, but if your request takes more than a short moment, the whole script execution, and potentially the page, will be halted until it returns.