0
How to consume a method Multipart/form-date of a web service made in java, by ajax or jquery?
Below I leave as this the method:
JAVA:
@POST
@Path("/aprovarCompra")
@Consumes("multipart/form-data")
public void aprovarCompra(@FormParam("nrCompra") Long nrCompra,
@FormParam("usuario") String usuario) {
//aqui faco as validacoes conecto ao banco e aprovo a compra
}
The front end is in nodejs (which I know almost nothing about, and the company chose to do so)
The code I have on the front end is as follows::
$('#aprovar').click(function(){
$.ajax({
type: "POST",
url:"10.0.2.15:7001/ws/resources/Compra/aprovarCompra",
contentType: "application/x-www-form-urlencoded",
data:'nrCompra=12345&usuario=usuarioMaster',
success: function (data) {
alert(data);
},
error:function (){
alert("error ao aprovar a Compra: "+nrCompra);
}
});
});
I need to consume the webservice by approving the purchase, on the web page with nrCompra and the user. I am trying to do this via ajax but if there is another way I am open to suggestions.
– user2913044
the call Ajax, arrives on the server?
– heber gentilin
It’s not coming, I don’t know why a friend asked to install Cors to try later. also I can change the form of the webservice soh need to be separated the front and back end codes
– user2913044
you have come to look at the call by the browser development tool network?
– heber gentilin
ola Heber thanks for the help, after installing the Cors plugins in google Chrome everything is working properly.
– user2913044