Is it possible to make 2 java scripts calls on single event (onClick) but the first javascript call must return immediately to show progress bar and second java script method call returns after processing. - madhusudana30/AlternativeJPAForWebSphere GitHub Wiki
It seems like not possible to return first javascript method to browser immediately without completing the second call.
onClick="mask(); repo()"
There are 2 solutions to this problem:
- Make a dummy ajax call and in response/error perform pdf operation. make sure to add timeout, it can BOMB in AIX environments
- Disable the button as soon as user clicks on Save Report Button and enable back the Save Report button after the print pdf action. document.getElementById("saveReportBtn").disabled = true; document.getElementById("saveReportBtn").disabled = false;
$.ajax({
type: "GET",
dataType: dataType,
contentType: contentType,
async: TRUE,
url: $('html form:nth-child(1)').attr('action') + "?" $('html form:nth-child(1)').serialize(),
success: function(data) {
console.log("FUNFOU!");
},
error: function(data) {
console.log("NÃO FUNFOU!");
},
complete: function(data) {
console.log("SEMPRE FUNFA!");
//A function to be called when the request finishes
// (after success and error callbacks are executed).
}
});