Gönderme jQuery Ajax post verilerini yakalamak

0 Cevap php

Yani JQuery ajax işlevini kullanarak form verilerini yolluyorum. Bu tüm i veriler mesajları yakalamak mümkün değil ne kadar hiç iyi iş gibi görünüyor.

Ben $ dize kullanmaya çalışıyorum = $ _POST ['isim'] hiçbir şans ile gönderir sayfadaki sonuç yakalamak için.

JQUERY-

$(function() 
{  
    $('.error').hide();
    $(".button").click(function() {  
    // validate and process form here

    $('.error').hide();  
      var name = $("input#name").val();  
      if (name == "") {  
      $("label#name_error").show();  
      $("input#name").focus();  
      return false;  
    }  
      var email = $("input#email").val();  
      if (email == "") {  
      $("label#email_error").show();  
      $("input#email").focus();  
      return false;  
    }  
      var phone = $("input#phone").val();  
      if (phone == "") {  
      $("label#phone_error").show();  
      $("input#phone").focus();  
      return false;  
    } 

      var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone;  
      //alert (dataString);return false;  
      $.ajax({  
        type: "POST",  
        url: "from_text_script.php",  
        data: dataString,  
        success: function() {  
        window.location.href="from_text_script.php"

        }  
      });  
    return false;
  });  
}); 

DAN-

<form name="contact" action="">  
  <fieldset>  
    <label for="name" id="name_label">Name</label>  
    <input type="text" name="name" id="name" size="30" value="" class="text-input" />
    <label class="error" for="name" id="name_error">This field is required</label><br/> 
    <label for="email" id="email_label">Return Email</label>  
    <input type="text" name="email" id="email" size="30" value="" class="text-input" />  
    <label class="error" for="email" id="email_error">This field is required.</label>  <br/> 

    <label for="phone" id="phone_label">Return Phone</label>  
    <input type="text" name="phone" id="phone" size="30" value="" class="text-input" />  
    <label class="error" for="phone" id="phone_error">This field is required.</label>  <br/> 

    <br />  
    <input type="submit" name="submit" class="button" id="submit_btn" value="Send" />  
  </fieldset>  
</form>  

/div> -->

Sorry about the typed code not being a screen shot. The site won't let me post images yet. Kind of silly really. Anyway... Cheers guys.

0 Cevap