I am trying to change the content of div "info" using the script as shown below
But We can see that the content of the div is changing in the inspected screen and Not reflecting in the browser screen.
Please help me to fix this issue.
function GeneratePaySlips() {
ShowLoaderOnElement(".btn-generate");
if ($("#driverIDs").val().length > 0) {
var i = 0;
var driverIDs = $("#driverIDs").val().split(',');
//for (var i = 0; i < driverIDs.length; i++)
for (i = 0; i < 5; i++) {
document.getElementById("info").innerHTML = i + 1 + ' of ' + $("#totalDrivers").val();
$.ajax({
type: "POST",
data: { "driverID": driverIDs[i] },
async: false,
cache: false,
url: '/BulkPaySlip/GeneratePaySlip',
success: function (response) {
if (response.isSuccess) {
}
else {
}
},
error: function (response) {
HideLoaderOnElement(".btn-generate");
},
complete: function () {
}
});
}
if (i >= driverIDs.length) {
HideLoaderOnElement(".btn-generate");
}
}
}
2
Answers
So I can’t see all the code but maybe put the code in a < script > tag right before the html element and then see what happens.
First of all
innnerHTML
is used to change the content of the specified element you called. On your above codes, the contents will go to the div element without creating any elements tags thus not displaying the content you wanted.The below code can work if you need to create another element on DIV tag
or you can try and create a new element which you can later append to the div five times according to your for loop. Run the code below
The codes are self-explanatory, sorry for mentioning this.