A doubt. In this example:
This is just a test where the api-clients-edit.php page receives the data, saves it and returns the status.
var dados = $("#editarClientes").serialize();
dados += "&id="+meuID;
console.log(dados);
$.ajax({
type: "POST",
url: "../api/api-clientes-editar.php",
data: dados,
dataType: 'json',
success: function(retorno,status){
console.log(retorno);
console.log(status);
},
error: function(retorno,status){
console.log(retorno);
console.log(status);
}
});
When the data is serialized, viewing the console.log, using "serialize" is in the format:
campo1=dado1&campo2=dado2&campo3=dado3
Now, if we use "serializeArray" the data is in the format:
campo1 : dado1, campo2: dado2, campo3: dado3
It is well known that we can pass on the hand too, without using the serialize. But this makes it easier:)
Question: When would it be useful to use one format or another?
Another thing. I needed to add the ID in the "data" string. That's why I used serialize. But if it was in the serializeArray format, how would you add this information?