I have the following code in my jsp, and what I want to do is that when I click on the button, it sends me to another page to show the report, what it does is that if it enters my method that I have in the controller but shows nothing or marks error
<script>
function generarDocumento(){
var data = "consultaForm";
var url: "${pageContext.request.ContextPath}/report";
$.ajax({
type: "POST",
url: url,
contentType: "application/json",
data: data,
dataType: 'json',
});
}
</script>
<form id="consultaForm">
<button type="button" onclick="generarDocumento();">GENERAR</button>
</form>
and the code in my controller
@RequestMapping("/report")
public String verReporte(Model model, @RequestParam(name = "format", defaultValue="pdf", required = false) String format{
model.addAttribute("format", format);
model.addAttribute("datasource", facturaService.consultaAll());
model.addAttribute("autor", "Dev");
return "prueba_reporte";
}
and that is if I enter the url /report
directly in the browser if you show me my report, but I want to do it from my button of my jsp
How can I do it?
What do I have to change to send it from my button? Thanks -