You can do it with an async request, but it's generally a Bad Thing
Something like the following oughta return the data.
function Profiles() { };
Profiles.prototype.test = function() {
var returnedResponse;
var opt = {
async: false,
url: __profileurl__+'getall/', type: 'get', dataType:'json',
success:function(response){
returnedResponse = response;
}
};
$.ajax(opt);
return returnedResponse;
};
BUT
Unless you really really need to be able to use the return value from test straight away, you'll be much better off passing a callback into test. Something like
Profiles.prototype.test = function(callback) {
var opt = {
url: __profileurl__+'getall/', type: 'get', dataType:'json',
success:function(response){
callback(response);
}
};
$.ajax(opt);
};
var profile = new Profiles();
profile.test(function(data) {
// do something with the data
});