Use Ajax to get some data from the server, if successful, the query process them and give callback function, where again, doing some manipulation. The request is sent synchronously as it is in a loop and goes 4-10 times in a row to get different data. But the problem is that while the work requests, the page is completely blocked. From here the question: either how to perform synchronous requests without blocking the page, or how to make the queries async, but obtaining information, now if you do requests instead of asynchronous data in callback function comes up undefined, as it is called before the response from the server.
Here is the query itself:
var jqxhr = $.ajax({
type: "POST",
url: "/mycontroller/myaction",
dataType: "json",
async: false,
cache: true,
data: {data : mydata},
error: function(event){
console.log("fail");
return callback(false);
},
success: function(event){
console.log("ok");
//Here am processing the data using the data received from the server
return callback(event);
}
});