Obtener data de contacto con jquery ajax
AUTOR PREGUNTA #1
Les dejo el codigo HTML y el jquery para que me ayuden a identificar el problema:
HTML:
<form id="sForm" action="submit.php" method="get"> <label>your e-mail: </label> <input type="text" name="email"></input> <input id="sub" type="submit" /> </form> <div id="message_ajax"> </div> <div id="error"></div>
jQuery:
$("#sub").click(function(){
var datastr = 'email'
$.ajax({
type: 'GET',
url: 'submit.php',
data: datastr,
beforeSend:function(){ $('#message_ajax_wait').append('Cargando...'); }, success:function(data){ $('#message_ajax_wait').fadeOut(400); $("#message_ajax_done").append('hecho!'); }, error:function(){ $('#error').append('error en el servidor'); } }); return false; });
-
¿Tienes la misma pregunta? Yo también
Esto también te interesa!
PREGUNTAS SIMILARES
#4
var datastr = $("#sForm").serialize();O añadiendolo a un string primero:
$.ajax({
type: 'GET',
url: 'submit.php',
data: $("#sForm").serialize(),beforeSend:function(){ .... };