2016-07-21 206 views
-1

我有以下的HTML代碼,我不知道如何發送數據(電子郵件)到PHP變量。提交後,變量$ _POST ['email']不起作用。也許由阿賈克斯後會工作,但我不知道如何,有人可以幫助我嗎?謝謝。通過ajax發送表單?

<div id="newmember" class="form-1"> 
          <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> 
           <div class="modal-dialog"> 
           <div class="modal-content">   
            <div class="modal-body"> 
             <div class="row"> 
              <div class="col-md-12 text-center"> 
               <div class="pop-up">        
                <div class="box-1"> 

                </div> 
                <img src="img/6.png" class="center-block" alt=".."> 

                <div class="form-search space40"> 
                 <form action="index.php" method="post"> 
                  <div class="input-group input-group-lg mtop-10"> 
                   <input type="text" name="email" class="form-control input-lg" placeholder="Your email"> 
                   <span class="input-group-btn"> 
                    <input type="submit" name="send" class="btn btn-lg-sub model-btn" data-target="#login" id="model11" data-toggle="modal" data-dismiss="modal"><i class="fa fa-paper-plane" aria-hidden="true"></i> &nbsp; SEND</button> 
                   </span> 
                  </div> 
                 </form> 
                </div> 
                <div class="space30"></div> 
                <div> 

                </div> 
                 <div class="space30"></div> 

               </div> 
              </div> 
             </div>      
            </div>       
           </div>     
           </div> 
          </div><!-- end become a member modal --> 
         </div> <!-- end Form --> 
         <!-- Modal Login --> 
         <div class="form-1" id="logingform"> 
          <div class="modal fade" id="login" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> 
           <div class="modal-dialog"> 
            <div class="modal-content"> 
             <div class="modal-content">             
              <div class="row"> 
               <div class="col-md-12 text-center"> 
                <div class="pop-up"> 

                 <div class="box-1"> 
                  <h3><i class="fa fa-check-square-o" aria-hidden="true"></i> &nbsp; SENT</h3> 
                 </div> 
                 <img src="img/6.png" class="center-block" alt=".."> 
                 <div class="space40"></div> 
                 <h4>Thank you for email.</h4> 
                 <div class="space60"></div> 

                </div> 
               </div> 
              </div> 
             </div> 

            </div> 
           </div> 
          </div> 
         </div> 
+0

你做的var_dump($ _ POST)中的index.php?它打印什麼? – Grommy

+0

當我刪除data-dismiss =「modal」時,表單submits和var_dump就可以了。 – martyyyy

回答

-1

ajax調用看起來像這樣。

$.ajax({ 
    url: "YOUR_URL_HERE", 
    type: "POST", 
    success: function(response){ 
    // Do something on success. 
    } 
}); 

你可以把上面的代碼中的函數,調用它,並給它一個URL

function postRequest(url){ 
    $.ajax({ 
    url: url, 
    type: "POST", 
    success: function(response){ 
     // Do something on success. 
    } 
    }); 
} 
+0

爲什麼這麼多人跑到JQuery?姆。 –