2017-05-07 33 views
-1

通過我的理解AJAX旅程提交表單我想出了這個問題,我不知道如何解決它首先IM在我的表請求DATAS如何從Ajax回調

load_data(); 
function load_data(page) 
     { 
      $.ajax({ 
       url:"data.php", 
       method:"POST", 
       data:{page:page}, 
       success:function(data){ 
        $('#result').html(data); 
       }, 
       error:function(exception){alert('Exeption:'+exception);}     
      }) 
     } 

這是隻是表,其中將輸出

<table> 
     <thead> 
      <tr> 
       <th>name</th> 
       <th>details</th> 
       <th>price</th> 
       <th></th> 
      </tr> 
     </thead> 
     <tbody id = "result"> 

,這是從網絡選項卡中的輸出

Response from network tab

有一個從我試圖用這個jQuery提交其形式來激活它的響應按鈕,但是,這並不工作

$(document).on('click', '#add_details', function(){ 
     $(this).parents("form").submit(); 
    }); 
+1

其中'add_details' – brk

+0

哪裏邏輯的其餘部分的ID?何時/何處執行'load_data()'? – YoannM

+0

爲什麼不**父母**而不是**父母**? –

回答

0

添加ID到你需要用按鈕提交表單點擊喜歡

<form id="myForm1"> 
//Other Code Here 

,並與您的按鈕即可使用您添加

$(document).on('click', '#add_details', function(){ 
     $("#myForm1").submit(); 
});