3
A doubt. In this example:
This is just a test where the api-clients-edit.php page receives the data, saves 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" are 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 known that we can pass in the hand also, without using the serialize. But so it facilitates :)
Question: When it would be useful to use one format or another?
Another thing. I had to add the ID in the "data" string. That’s why I used serialize. But if it was in serializeArray format, how would you add that information?
I had already seen this original post. It says it’s useful when I want to process the results myself. I just didn’t understand. As an example of "process results"?
– bur