首页 > 解决方案 > 无法使用 ajax 功能显示选项卡

问题描述

如何编写和调用函数来显示/隐藏 ajax 标记之外的 div?使用 OnClick 事件处理程序(我显示了一条警报消息,但该功能不起作用)

                        if ((data[i + 1].deviceName == data[i].deviceName) && (data[i + 1].protocol == data[i].protocol)) {
                            divbody += "<tr style=\"border-bottom:solid; border-width:thin\">";
                            divbody += "<th><input type=\"radio\" name=\"device\" onclick=\"alert('Hi_2')\" value=\"" + counter++ + "\"></th>";
                            divbody += picurl;
                            divbody += "<th style=\"padding:10px\">" + data[i].deviceName + "(" + data[i].protocol + ")" + "</th>";
                            divbody += "<th>" + data[i].display_Name + " : " + data[i].value + data[i].unit + " & " + data[i + 1].display_Name + " : " + data[i + 1].value + data[i + 1].unit + "</th > ";
                            divbody += "<th>" + data[i].timeStamp + "</th>";
                            divbody += "<th><img src=\"../wwwroot/images/Battery.png\" style=\"width:150px; height: 150px;\" /></th>";
                            divbody += "</tr>";
                            i++;

名为“设备”的单选按钮


<script>
    $(document).ready(function () {
        $("input[name$='device']").checked(function () {
            $.ajax({
                url: "#myTabs", success: function (result) {
                    $("#tbl-productos").html(result);
                }
            });
        });
    });
</script>

功能尝试

标签: javascriptajaxasp.net-ajax

解决方案


推荐阅读