Fist of all, there is a typo. It should be <form id="datos-add">
instead of <form id="#datos-add">
.
But I also think you are serializing it the wrong way.
When you do a POST ajax call, you shoud use .serializeArray()
, instead of .serialize()
.
The .serialize()
will join all key/values like a query string.
The .serializeArray()
will include all key/values in the request.
In short, try:
$('#add-producto').click(function (e) {
$.ajax({
type: "POST",
url: "insertar.php",
data: $('#datos-add').serializeArray(),
success: function (data) {
alert(data);
}
});
e.preventDefault();
});