2015-04-07 3 views
0

Я пытаюсь передать форму для $ .ajax, но когда я доберусь до части успеха: блок функций (данных) .... Я ' м не эксперт в этом и просто начать заниматься программированием, если кто-то достаточно любезен, чтобы объяснить, как poderme отправить «Notify», вот мой код:

<script> 
$(function () {  
    $("#contacto_web").submit(function(e) { 
    e.preventDefault(); 
    $.ajax({ 
     url : "contacto_web.php", 
     type : "POST", 
     data : { 
      $("#contacto_web").serialize(); 
     }, 
     before : function() { 

     }, 
     success : function (data) { 
      if(data == "si_enviado"){        
       $UIkit.notify({ 
        message : 'Bazinga!', 
        status : 'info', 
        timeout : 5000, 
        pos  : 'top-center' 
       }); 
      }else if(data == "no_enviado"){ 
       $UIkit.notify({ 
        message : 'Bazinga!', 
        status : 'danger', 
        timeout : 5000, 
        pos  : 'top-center' 
       }); 
      } 
     }, 
     error : function() { 

     }, 
    }); 
    });  
}); 
</script> 

UIKit Framework Ссылка:

Component Notify

php code:

<?php 

if(filter_input_array(INPUT_POST)){ 

    $nombres = filter_input(INPUT_POST, "nombres"); 
    $apellidos = filter_input(INPUT_POST, "apellidos"); 
    $tlfno1 = filter_input(INPUT_POST, "tlfno1"); 
    $tlfno2 = filter_input(INPUT_POST, "tlfno2"); 
    $email1 = filter_input(INPUT_POST, "email1"); 
    $email2 = filter_input(INPUT_POST, "email2"); 

    $nombre_razonsocial = filter_input(INPUT_POST, "nombre_razonsocial"); 
    $pais = filter_input(INPUT_POST, "pais"); 
    $direccion = filter_input(INPUT_POST, "direccion"); 
    $sms_form = filter_input(INPUT_POST, "sms_form"); 

    $to = "[email protected]"; 
    $title = "Correo de contacto desde la pagina web"; 
    $headers = "From: $email1" . "\r\n"; 
    $message =" 
    Contacto desde la pagina web\n 
    $nombres $apellidos\n  
    Telefono $tlfno1 | Movil $tlfno2\n 
    Correo principal $email1, Correo alternativo $email2\n\n 
    Nombre/Razon social $nombre_razonsocial\n 
    Pais de procedencia $pais\n 
    Direccion $direccion\n 
    Mensaje\n 
    $sms_form 
    "; 

    if(mail($to,$title,$message,$headers)){ 
     echo "si_enviado";   
     }else{ 
     echo "no_enviado"; 
     } 

} 

ответ

0

Soluction:

$(function() { 
    $("#contacto_web").on("submit", function(event) { 
    event.preventDefault(); 
    $('#output').text(($(this).serialize())); 
    UIkit.notify({ 
          message : 'Enviando mensaje...', 
          timeout : 5000, 
          status : 'success' 
         }); 
    $.ajax({ 
       url : "contacto_web.php", 
       type : "POST", 
       data : $(this).serialize(), 
       before : function() { 

       }, 
       success : function (data) { 
        if(data == "si_enviado"){       
         UIkit.notify({ 
          message : 'Mensaje enviado, Gracias!', 
          status : 'info', 
          timeout : 5000, 
          pos  : 'top-center' 
         }); 
        }else if(data == "no_enviado"){ 
         UIkit.notify({ 
          message : 'Mensaje no enviado!', 
          status : 'info', 
          timeout : 5000, 
          pos  : 'top-center' 
         }); 
        } 
       }, 
       error : function() { 

       }, 
      }); 
    }); 
}); 
Смежные вопросы