I am creating a file providing data got from ajax call using following code.
$.ajax({
url: xxx,
type: "POST",
data: path,
contentType: "text/plain; charset=utf-8",
async: false,
success: function (data, textStatus, xhr) {
if (xhr.status == 200) {
var file = new File({
name: 'abc.xyz',
path: 'path/to',
content: data.content
});
} else {
}
}
This operation fails with following browser console error
Uncaught TypeError: Failed to construct 'File': 2 arguments required, but only 1 present.
at Object.success (BaseTest.js:44)
at n (jquery.min.js:2)
at Object.fireWith [as resolveWith] (jquery.min.js:2)
at w (jquery.min.js:4)
at d (jquery.min.js:4)
at Object.send (jquery.min.js:4)
at Function.ajax (jquery.min.js:4)
at myFunction (BaseTest.js:32)
at BaseTest.js:21
at Function.req.execCb (require.js:1660)
What is the reason for this issue ?
Note: var f = new File([""], "filename.txt", {type: "text/plain", lastModified: date})
is working fine but what is the error with my approach