I'm writing a website which heavily utilises Javascript and Ajax calls to a Python web server (Flask). The problem I'm having is that the calls usually lag or freeze the page for a brief moment giving a bad user experience. This occurs when sending a POST
request to my Python script with the following Ajax-style call:
var getUniversities = function() {
var unis;
$.ajax({
url: '/get/universities',
type: 'POST',
data: 'uid=1',
dataType: 'json',
async: false,
success: function(data) {
unis = data;
}
});
return unis;
};
This is the general way I'm making Ajax requests and all of them generate some form of lag for my webpage. I believe it's because I'm trying to do it synchronously, but I can't see a way to retrieve data and have it ready for processing asynchronously.
Thanks