weixin_33725807
2019-11-27 08:50
采纳率: 0%
浏览 34

Ajax加载表数据

Request your help, as the below line of code if not loading the data into the table when i choose the related radio button, not sure what is wrong nor missing, if there is any alternate way other then this please do let me know.

Code

<div>
<label class="form-check-label><input type="radio" class="form-check-input" name="Gender" value="M" checked>Male</label>
<label class="form-check-label><input type="radio" class="form-check-input" name="Gender" value="F" checked>Female</label>
</div>
<div class="row" id="Dbackup">
<table id="Backup">
<thead>
<tr>
<th>Name</th><th>Gender</th>
</tr>
</thead>
<tbody>
<tr><td>xxxx<</td><td>Male</td></tr>
.
.
<tr><td>xxxx<</td><td>Female</td></tr>
</tbody>
</table>
</div>

**Ajax script**
<script type="text/javascript">
$(document).ready(function(){
$("input[type='radio']").on('click', function(){
    var radioValue = $("input[name='Gender']:checked").val();
    $.ajax({
            url: "/gdata/" + radioValue,
            method: "GET",
            data:{rvalue:radioValue},
            success: function(data){
                     $('#Backup').load(data);
                    }
   });
});
});
</script>

From, Vino

图片转代码服务由CSDN问答提供 功能建议

                    

请寻求帮助,因为下面的代码行如果我选择相关的单选按钮时未将数据加载到表中,则不确定是什么错误也不丢失,如果还有其他替代方法,请让我 知道。</ p>

代码</ strong> </ p>

  
<label class =“ form-check-label> <输入类型=” radio“ class =” form-check-input“ name =”性别“ value =” M“已选中>男性</ label> <label class =“ form-check-label> <输入类型=” radio“ class =” form-check-input“ name =”性别“ value =” F“已选中>女性</ label> </ div>
姓名</ th> 性别</ th> </ tr> </ thead> <身体>
xxxx << / td> 男性</ td> </ tr> 。 。
xxxx << / td> 女性</ td> </ tr> </ tbody> </ table> </ div> ** Ajax脚本** <script type =“ text / javascript”> $(document).ready(function(){ $(“ input [type ='radio']”)。on('click',function(){      var radioValue = $(“ input [name ='Gender']:checked”)。val();      $ .ajax({              网址:“ / gdata /” + radioValue,              方法:“ GET”,              数据:{rvalue:radioValue},              成功:功能(数据){                       $('#Backup')。load(数据);                      }     }); }); }); </ script> </ code> </ pre>

来自 酒</ p>      </ div>

相关推荐 更多相似问题