php - Catching Post data from Jquery Ajax From Submission -


so sending form data using jquery's ajax functionality. seems work okay how ever not able catch data posts.

i trying use $string = $_post['name'] catch result on page sends no luck.

the jquery-

$(function()  {       $('.error').hide();     $(".button").click(function() {       // validate , 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;   });   });  

the from-

<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 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 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 required.</label>  <br/>       <br />       <input type="submit" name="submit" class="button" id="submit_btn" value="send" />     </fieldset>   </form>   

/div> -->

sorry typed code not being screen shot. site won't let me post images yet. kind of silly really. anyway... cheers guys.

i'm not sure you're trying do, why success function redirect same page you're posting to?

try doing on page post to:

var_dump($_request);

that print out got passed , maybe can see what's going on.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -