2017-05-07 60 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(); 
});