This code will show an error: TypeError: Function expected
function btnUploadImageEvent() {
$(document).on("click", "#btn-upload-image", function () {
// Iterate all td's in second column
$("#table-image tbody tr:not(:first-child)").each(function (index, value) {
var blob = value.cells[5].innerText;
var fileName = (index + 1) + ".jpg";
srcToFile(blob, fileName, "image/jpeg")
.then(function (file) {
var formData = new FormData();
formData.append("file", file);
PassingBlobToServer(formData);
}, function (error) {
MsgBox("Error", error, "error", "#upload-image-modal");
}).then(function () {
});
});
});
}
function srcToFile(src, fileName, mimeType) {
return (fetch(src)
.then(function (res) { return res.arrayBuffer(); })
.then(function (buf) { return new File([buf], fileName, { type: mimeType }); })
);
}
I read this article already: https://learn.microsoft.com/en-us/scripting/javascript/misc/function-expected
However, I'm still not understanding what MS say. This must be something wrong in my code. Please help me, thanks a lot.