today I am stacked with some question about async work of jquery ajax.I am pretty new to js and especially for jquery.
After click on button new tab opened and filled with pretty long request(a lot of data returned) and freeze other part of site (tab wi button) until request is done. Is there any possibilitty to make it work async, so my old tab will work while request computating?
Current js code for open new window
window.open(request, '_blank')
Which one obviously not async
May be something like
Var O = window.open() ; O. Ajax(blablabla)
UPD:
I solved problem by creating new element with rel="norefferer" and imitate click on that element, so new tab will open in new process and don't block main tab
AJAX is async (it literally means "asynchronous JavaScript and XML").
You just need to use it properly, as follow :
$.ajax({
url: "https://www.example.com",
"success": function(result) {
// This part will be called after the ajax request was successful
/*
insert your code here,
but be aware that, as CBroe noted in the comments,
window.open() could be blocked by modern browser
*/
}
});
Read the jquery documentation on AJAX for more info.