0
I have doubts if I am passing the data correctly by the date, is the syntax correct? I’m sending it to the.php receiver and trying to get it with POST['imagemdomeumodel']; and it doesn’t work.
$('#novo').on('submit',function(e) {
e.preventDefault();
form = document.getElementById('novo');
var data = new FormData(form);
$.ajax({
url:'ajaxDoEnvioDeEmail.php',
type:'post',
data:{'imagemdomeumodelo':data},
contentType:false,
processData:false,
success:function(msg) {
console.log(msg);
$('.envios').show();
$('.envios').html(msg);
},
beforeSend: function() {
$('.divtop').hide('fast');
$('.carregando').fadeIn('slow');
},
complete:function() {
$('.carregando').fadeOut('slow');
$('.sucesso').fadeIn('slow');
$('.envios').show();
$('.sucessow').fadeIn('fast');
}
});
});
Instead of
data:{'imagemdomeumodelo':data}
do sodata: data
– NoobSaibot
But I want to send you more information, like date:date+otherVariavelComNamesDoFormularioHtml
– Mailiane
How to do this?
– Mailiane
You can do so, as you created the variable
data
and its value is the interfaceFormData
you can use the methodappend
, see:data.append('nome', 'Fulano de Tal');
, thus, it will be added in the value of the variabledata
as if what you put is a form element.– NoobSaibot
If you want to post an object in your attribute, I think you’ll need to serialize it first (take a look at this: https://www.w3schools.com/js/js_json_stringify.asp)
– Leandro Angelo
Wm Souza thanks, but I opted for another solution, I put an input Hidden and picked up bag?
– Mailiane
append serves to add html element right? What is it like?
– Mailiane
$( ".container" ).append( $( "H2" ) ); I have already searched here, in this case I am adding an H2 inside a div called containter.
– Mailiane
There are several
append
, one of them is the one you quoted, used in jQuery, the one I said is specifically interfaceFormData
, see the documentation in Português. You can also use it like this:data.append('nome', $('nome_do_campo_html').val());
– NoobSaibot