From the data in form
post.id = "submit";
First you will need to get the data of this form, right after doing the append in the document
var _url = "caminho/para/o/arquivo.php"
var _data = new FormData($("#submit")[0]);
So you can use ajax function from form
$.ajax({
url: _url,
type: 'POST',
data: _data,
timeout: 20000,
processData: false,
contentType: false,
success: function (data) {
//Código para resposta da requisição
}, error: function(data){
//Código para falha na requisição
});
processData: false and contentType: false - > does not transform date into Json format for FormData, since it is already a FormData
You can also pass an array but you should use the following code
$.ajax({
url: _url,
type: 'POST',
data: {name1:array(valor1,valor2),name2:array(valor3,valor4)},
timeout: 20000,
success: function (data) {
//Código para resposta da requisição
}, error: function(data){
//Código para falha na requisição
});
processData and contentType - > in default setting transforms date into Json format for FormData
In case you do not need to create form