[! [enter the description of the image here] [2]] [2] I am trying to send a form via ajax, to prevent the page from refreshing:
function form(){
$.ajax({
type: 'POST',
url: 'formulario.php',
data: $('#formulario').serialize(),
success: function(data) {
console.log("sin refresh");
}
});
}
HTML
<form action="formulario.php" method="post" name="formulario" id="formulario">
<input type="text" name="name" class="form-control" id="name" placeholder="Your Name..." required>
<input type="text" name="company" class="form-control" id="company" placeholder="Company..." required>
<input type="email" name="email" class="form-control" id="email" placeholder="Your Email..." required>
<p style="font-size: 15px; margin-left: 12px;">
What service interests you?
<select name="service">
<option>Compliance</option>
<option>Cybersecurity</option>
<option>Network Engineering</option>
</select>
</p>
<br>
<textarea name="message" class="form-control" id="message" placeholder="Messages..." required></textarea>
<input type="checkbox" name="condiciones" id="condiciones" value="1" required>
<a href="privacy.html" target="new">I have read the privacy notice</a><br><br> <button type="button" class="btn btn-blue btn-effect" id="enviar" onClick="form()" style="color: white">Send</button>
</form>