Good afternoon, I'm making a form that sends an email and stores the data in a database. It runs correctly in Chrome, Firefox, Microsoft Edge and Safari (but the latter only in the desktop version, the insertion in the database does not occur when the process is done from an Ipad or an Iphone). Attached the fragment that is responsible for the insertion in the database.
function envioMensaje()
{
$('#Formulario').on("click",'#solicitar', function(ev) {
ev.preventDefault();
var datos={
"nombre": $('#nombre').val(),
"telefono": $('#Telefono').val(),
"mail": $('#mail').val(),
"producto": $(':selected').val(),
"extraInfo": $('#otrosArticulos').val()
}
var datosMensajes={
"nombre": $('#nombre').val(),
"telefono": $('#Telefono').val(),
"mail": $('#mail').val(),
"producto": $('#producto option:selected').text(),
"extraInfo": $('#otrosArticulos').val()
}
var mensaje = "envioMensajes.php";
var urlEnvio = "Proceso que ejecuta la insercion, la he eliminado por cuestion de privacidad".
$.ajax({
type:"post",
url:urlEnvio, //Para registro sin mensaje
jsonp: "callback",
dataType: "jsonp",
data:datos
//success: mensaje
});
$.ajax({
type:"post",
url:mensaje, //Para mensaje
jsonp: "callback",
dataType: "jsonp",
data:datosMensajes,
success: function(data){
}
});
}); window.location.href = "index_gracias.php#free-h";
};
I would greatly appreciate the help.
I add the part of the code that collects the data.
<form id="Formulario" name="formucontacto">
<div class="center">
<div id="free-h">
<h3>Pide tu demo <strong>Gratuita!</strong></h3>
<span><img src="images/icon-tlf.png" alt="Teléfono" width="24" height="34" align="absmiddle"/><a href="tel:+665458897">+665458897</a></span>
<fieldset>
<input type="text" id='nombre' name="nombre" placeholder="Introduce tu nombre..." required>
<input id='mail' name="mail" type = 'email' placeholder="Introduce tu correo electrónico" required>
<input id='Telefono' name="telefono" type = 'text' placeholder="Introduce tu telefono" required>
<select id="producto" required>
<option value="" default>-- Selecciona tu producto --</option>
<option value="1">Producto1</option>
<option value="2">Producto2</option>
<option value="3">Producto3</option>
<option value="4">Producto4</option>
<option value="5">Producto5</option>
<option value="6">Otro...</option>
</select>
<span class="legal">
<input name="condiciones" id='Condiciones' type="checkbox" required>Acepto la
<a style="color:#aaa; overflow:auto; text-decoration:underline;" onclick="window.open(this.href, this.target, 'width=400,height=720'); return false;" target="_blank" href="nota.html">política de privacidad.</a>
<div class="g-recaptcha" data-sitekey="6LfM6h8UAAAAAAGzSXe_abDnV3slmQdVOsO2elXz" data-callback="enableBtn"></div>
<!-- <div class="g-recaptcha" data-sitekey="Aqui va la clave de recaptcha Google" data-callback="enableBtn"></div> -->
</span>
<input type="submit" onClick = 'validarcontacto()' id="solicitar" value="SOLICITAR" disabled />
</form>
Basically, when validating the Captcha is when the REQUEST button is enabled, and clicking on it validates the fields, and then sends the data.