2
I have the following code on JavaScript
to post the form data on MySql
. However, I need you to display a "loading..." message before sending, because I use it to post photos and it takes a while.
<script type="text/javascript">
$(function(){
$('#feed_msg').submit(function(event){
event.preventDefault();
var formDados = new FormData($(this)[0]);
$.ajax({
url:'post-msg-grupo.php',
type:'POST',
data:formDados,
cache:false,
contentType:false,
processData:false,
success:function (data)
{document.getElementById('msginf').innerHTML = 'Parabéns! Sua mensagem foi enviada com sucesso!';
$('#feed_msg').each (function(){
this.reset();
});
},
dataType:'html'
});
return false;
});
});
</script>
before executing ajax just display the message... can be by displaying a div, or a simple
document.write("carregando...");
– Ricardo Pontual
@Ricardopunctual I’m a layman, where I put this code in the script I posted?
– Gladison
@Ricardopunctual I tried but it didn’t work.
– Gladison
can be within the Sumit function anywhere before the
$.ajax
, before the lineevent.preventDefault();
for all intents and purposes– Ricardo Pontual
@Ricardopunctual Gave error, it opens a new tab in the browser and appears "loading..". The Heart appears inside 'msginf'
– Gladison
this was just an example, the best would be to create a div with the message inside and display the div, which will be positioned somewhere that is very visible, is that I understood that your doubt was how to display the message only
– Ricardo Pontual