A loading popup dialog may appear
window.location = "someUrl"
or just just a link that sends an HTTP GET method, etc. I have done this successfully.
But now I want to do Ajax with HTTP POST. POST body has JSON as
{"val1":"key1", "val2":"key2"}
Then, on the servlet side, it reads JSON and executes a query on the database to retrieve data, and then generates Excel based on the query data.
The part that I canβt work with is the client side.
Assugming that my servlet is resources/report/schedulecreating an excel file.
This is not a popup download dialog when using Ajax :( Can someone help me how to have a boot dialog with Ajax?
function post25() {
var jsonInput = {};
jsonInput['δ½ζ₯εΊγ³γΌγ'] = "481";
jsonInput['ζ©ζ’°γ³γΌγ'] = "11";
jsonInput['δ½ζ₯ζ₯'] = "2000/01/01";
jsonInput = JSON.stringify(jsonInput);
var ajaxRequest = new XMLHttpRequest();
ajaxRequest.onreadystatechange = function() {
if(ajaxRequest.readyState == 4 && ajaxRequest.status == 200) {
var res = ajaxRequest.responseText;
}
else if(ajaxRequest.status == 409 || ajaxRequest.status == 500 || ajaxRequest.status == 204) {
alert(ajaxRequest.status);
document.getElementById("showMessage").innerHTML = ajaxRequest.responseText;
}
}
ajaxRequest.open("POST", "../resources/report/schedule", true);
ajaxRequest.setRequestHeader("Content-Type", "application/json");
ajaxRequest.send(jsonInput);
}
source
share