Search code examples
javascriptphpjquerysend

jQuery form doesn't send


I have this weird situation where my form doesn't send any data, but the page (which should only be displayed when the data is send) is shown.

I have this code now:


     [..]
     if(form == true){
      var gender = $("input[@name='rgender']:checked").val();
      var data = "name="+$("#name").val()+"&gender="+gender+"&country="+$("#country").val()+"&address="+$("#address").val()+"&zip="+$("#zip").val()+"&city="+$("#city").val()+"&mail="+$("#mail").val()+"&phone="+$("#phone").val()+"&checkin="+$("#checkin").val()+"&guests="+$("#guests").val()+"&time="+$("#time").val()+"&nights="+$("#nights").val()+"&remarks="+$("#remarks").val();
      $.ajax({
       url: "http://www.domain.nl/tmp/process.php", 
       type: "GET",    
       data: data,       
       cache: false,
       success: function(){
        $("#content").empty();
        $("#content").load('http://www.domain.nl/tmp/process.php');
       }
      });
      f.preventDefault();
     }
     [..]

I checked the data string with an alert() before and that one is working well

My php file looks like this, but I don't get any values

<?php
echo("GET: ".$_GET['name']);
?>


Solution

  • maybe this will help:

       success: function(result){
        $("#content").html(result);
       }
    

    In your code you are sending 2 ajax request. First with $.ajax and with some GET parameters, and second with $().load, but without any parameters. So actually you can simplify your code to this:

    if(form == true){
       var gender = $("input[@name='rgender']:checked").val();
       var data = "name="+$("#name").val()+"&gender="+gender+"&country="+$("#country").val()+"&address="+$("#address").val()+"&zip="+$("#zip").val()+"&city="+$("#city").val()+"&mail="+$("#mail").val()+"&phone="+$("#phone").val()+"&checkin="+$("#checkin").val()+"&guests="+$("#guests").val()+"&time="+$("#time").val()+"&nights="+$("#nights").val()+"&remarks="+$("#remarks").val();
       $("#content").load('http://www.cherrytrees.nl/tmp/process.php', data);
       f.preventDefault();
    }