I am in need of a better way to retrieve data from the my server and loading it into my application controller.
Currently, I am using jQuery's built in $.ajax
, but due to jQuery's focus on mostly UI/UX operations it doesn't wait for the result before return the results of a request, I don't know if I'm doing this right, but this is how I have it set up currently:
var get_data = function(){
var result = false;
$.get('/get/some/data').done(function(awesome_data){
result = awesome_data;
});
return result;
}
But this method doesn't work and just returns false
.
I've read that you can just tick the async
option to false, but if the user is in a high-latency environment, it can easily hang the whole application (The application I'm writing is pretty hefty).
Are there any other libraries that can do what I am trying to achieve, or is there a way to use jQuery.AJAX
so that I can retrieve data from the server non-asynchronously and without hanging the application?
Thanks for the help fellas.