2011-04-24 5 views
14

내가 원하는 것은 제출을 클릭 할 때 모든 양식 데이터를 process.php에 게시하고 싶습니다. process.php에 POST 데이터를 출력하고 싶습니다 ... 그럼 대체하십시오. process.php에서 수행 한 것과 결과 DIV의 모든 ...jQuery POST 양식 데이터

<script type="text/javascript"> 
    $(document).ready(function(){ 
     $("#myform").submit(function() {  
      $.ajax({ 
       type: "POST", 
       dataType: "html", 
       cache: false, 
       url: "process.php", 
       success: function(data){ 
        $("#results").html(data);      
       } 
      }); 
      return false; 
     }); 

     //$("#myform").submit(function() { 
      //$('#results').html("yay");      
     //} 
      // }); 
     //});   
    }); 
</script> 

<form name="myform" id="myform" action="" method="POST"> 
<!-- The Name form field --> 
    <label for="name" id="name_label">zoom</label> 
    <input type="text" name="zoom" id="zoom" size="30" value=""/> 
    <br> 
</select> 


<!-- The Submit button --> 
    <input type="submit" name="submit" value="Submit"> 
</form> 

<!-- FORM END ---------------------------------------- --> 


<!-- RESULTS START ---------------------------------------- --> 
    <div id="results">nooooooo<?PHP $_SESSION[''] ?><div> 
    <!-- <input type="image" name="mapcoords" border="0" src="mapgen.php"> ---- --> 
<!-- RESULTS END ---------------------------------------- --> 
+4

그래서, 문제는 무엇인가? – Nacho

+0

코드가 그렇게하는 것 같습니다 (감기 검사). 문제가 무엇입니까? – Halcyon

+0

그리고 무엇이 문제입니까? –

답변

6
$("#myform").submit(function() {  
    $.ajax({ 
     type: "POST", 
     data : $(this).serialize(), 
     cache: false, 
     url: "process.php", 
     success: function(data){ 
      $("#results").html(data);      
     } 
    }); 
    return false; 
}); 

테스트가

+0

나를 위해 큰 일을했습니다! –

33

당신은 012를 호출 할 수 있습니다전달 양식 데이터가 직렬화되었습니다. 다음과 같이하십시오 :

<script type="text/javascript"> 
     $(document).ready(function(){ 
      $("#myform").submit(function() {  
       $.post(
       'process.php', 
       $(this).serialize(), 
       function(data){ 
        $("#results").html(data) 
       } 
      ); 
       return false; 
      }); 
     }); 
</script> 
+1

덕분에 그 덕분에 그 매력을 – LabRaTT

+0

그 코드가 작동하지만 이제는 한 가지를 변경하고 싶습니다 ... 나는