$.ajax is a generic jQuery function.
You want to do something like this:
$(function() {
function LoadPersons(data) {
// do something with data
}
$.ajax({
type: 'POST',
url: url,
data: JSON.stringify(parameters),
contentType: 'application/json;',
dataType: 'json',
success: function(result) {
// do something with persons (data)
// e.g. LoadPersons(data);
}
});
});
In text form:
Your ajax success should be the bit that's responsible for doing something with the data after it's successfully been returned. Your previous method tries to return data before the AJAX method has necessarily been completed. You can just add the $.ajax method directly inside $(function() { .. }) so it's called upon page load.
Also, I recommend using a tool such as Firebug to examine the output / response of AJAX calls.