Javascript, ajax request return, generate file

Asked

Viewed 78 times

0

	newXHR.addEventListener('load', reqListener);
	newXHR.open('POST', 'http://nfse.vitoria.es.gov.br/aberto/op/imprimirNfe.cfm', false);
	var jsonData = { codNfe: vlNota };
	var formattedJsonData = "codNfe=" + vlNota;
	newXHR.setRequestHeader('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8');
	newXHR.setRequestHeader('Cache-Control', 'max-age=0');
	newXHR.setRequestHeader('Upgrade-Insecure-Requests', '1');
	newXHR.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	newXHR.responseType = "arraybuffer";
}catch(ex) {
	console.log('Erro ao abrir a URL');
	return false;
}

this code return me a pdf, wanted how do I create a file with the data I receive from this request

inserir a descrição da imagem aqui

  • You want to return the PDF or a link where the guy clicks and he performs the download?

  • i want to save a pdf on my pc with this information

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.