Closed tenzap closed 2 years ago
Async false means that those would be blocking sync calls. And UI won't allow any other activity. If these are moved to async, then the code execution should be moved to the oncomplete handler.
Async false means that those would be blocking sync calls. And UI won't allow any other activity. If these are moved to async, then the code execution should be moved to the oncomplete handler.
Can you elaborate please? I don't understand.
https://stackoverflow.com/questions/1478295/what-does-async-false-do-in-jquery-ajax
Essentially it means that the ajax call is a sync call and the execution is blocked until the response comes. So this is more of sequence call (this is very bad).
var notif = ....
$.post(delete_url + source, {
type: 'conversation',
number: $(this).val(),
current_folder: current_folder
...
}, function(data) {
if (!data) {
$(message_row).slideUp("slow");
$(message_row).remove();
} else {
notif = data;
}
});
//now you can use the updated notif here.
show_alert(notif); //example usage
The way to solve this would be
$.post(...., function(data) {
//use the data now and continue execution here.
show_alert(data);
}).
Thanks, but I still don't understand this and the oncomplete handler:
This change needs to be updated so that the following statements are moved inside the oncomplete handler
BTW, here we are in a loop in which POST calls are made. Does that change something to your answer?
@kingster , I close this. Maybe you want to give a try.
Any idea why these were here? To avoid multiple DB calls at the same time?