I want to store an object in a restful server. I tried with an html form and everything works correctly but using javascript it doesn't work.This is the code
var app2={"user_id" : seleVal, "name":nome2, "img":img2, "type":tipo2, "supplier_id": distro}
$.ajax({
type: "POST",
url: 'http://localhost:8000/products',
data: app2,
success: alert("success"),
error: alert("error"),
});
the code get into success and error at the same time so I tried to catch the error making functions inside them but when I do that success and error seem to don't responde.Thank you for the help