Below code is used to display the image in new tab if the extension is jpg.
Similarly, I want to write a text document (from base64 string to text) in new tab if the extension is txt.
success: function (data) {
var extension = fileName.split('.').pop();
if (extension == "jpg") {
var image = new Image();
image.src = "data:image/jpg;base64," + data.d;
var w = window.open("");
w.document.write(image.outerHTML);
}
else if(extension == "txt") {
}
}