Javascript HTML表的Json对象

Javascript HTML表的Json对象,javascript,jquery,json,jscript,github-api,Javascript,Jquery,Json,Jscript,Github Api,我有一个带有“按钮/链接”的简单页面,当我按下按钮时,我需要调用github api以返回我的存储库中记录的所有问题并以表格格式显示 但是当我点击链接时,什么都没有发生 <html> <head> <script src="json-to-table.js"></script> <script src="js/jquery-1.10.2.min.js"></script> <script

我有一个带有“按钮/链接”的简单页面,当我按下按钮时,我需要调用github api以返回我的存储库中记录的所有问题并以表格格式显示

但是当我点击链接时,什么都没有发生

   <html>
<head>

    <script src="json-to-table.js"></script>
    <script src="js/jquery-1.10.2.min.js"></script>
    <script src="script.js"></script>
    <script src="script.responsive.js"></script>

</head>
<body>

    <h2>All Issues</h2>
    <a href="#" id="ghsubmitbtn" class="art-button">VIEW</a>

    <div id="ghapidata" class="clearfix">

<script type="text/javascript">

    $(function() {
        $('#ghsubmitbtn').on('click', function(e) {
            e.preventDefault();
            $('#ghapidata').html('<div id="loader"><img src="css/loader.gif" alt="loader..."></div>');

            var ghissues = 'https://api.github.com/repos/stroes/stroestest/issues';

            requestJson(ghissues, function(json) {
                if(json.message == "Not Found") {
                    $('#ghapidata').html("<h2>No Issues found in this repository</h2>");
                }

                else {
                    var jsonHtmlTable = ConvertJsonToTable(ghissues, 'jsonTable', null, 'Download');

                }

            }
        }
    });





</script>

    </div>
</body>
</html>

所有问题
$(函数(){
$('ghsubmitbtn')。在('click',函数(e){
e、 预防默认值();
$('#ghapidata').html('');
var GhRhttps://api.github.com/repos/stroes/stroestest/issues';
requestJson(问题,函数(json){
if(json.message==“未找到”){
$('#ghapidata').html(“在此存储库中未找到任何问题”);
}
否则{
var jsonHtmlTable=convertJsonTable(ghissues,'jsonTable',null,'Download');
}
}
}
});

有人能告诉我代码哪里出了问题吗?

您的脚本在div标记内。当您更改其中的html时,整个脚本将被删除。请尝试将脚本放在div标记外

<html>
<head>
<script src="json-to-table.js"></script>
<script src="js/jquery-1.10.2.min.js"></script>
<script src="script.js"></script>
<script src="script.responsive.js"></script>

</head>
<body>

<h2>All Issues</h2>
<a href="#" id="ghsubmitbtn" class="art-button">VIEW</a>

<div id="ghapidata" class="clearfix"></div>

<script type="text/javascript">

 $(function() {
    $('#ghsubmitbtn').on('click', function(e) {
        e.preventDefault();
        $('#ghapidata').html('<div id="loader"><img src="css/loader.gif" alt="loader..."></div>');

        var ghissues = 'https://api.github.com/repos/stroes/stroestest/issues';

        requestJson(ghissues, function(json) {
            if(json.message == "Not Found") {
                $('#ghapidata').html("<h2>No Issues found in this repository</h2>");
            }

            else {
                var jsonHtmlTable = ConvertJsonToTable(ghissues, 'jsonTable', null, 'Download');

            }

        }
    }
});

所有问题
$(函数(){
$('ghsubmitbtn')。在('click',函数(e){
e、 预防默认值();
$('#ghapidata').html('');
var GhRhttps://api.github.com/repos/stroes/stroestest/issues';
requestJson(问题,函数(json){
if(json.message==“未找到”){
$('#ghapidata').html(“在此存储库中未找到任何问题”);
}
否则{
var jsonHtmlTable=convertJsonTable(ghissues,'jsonTable',null,'Download');
}
}
}
});


您应该在控制台中看到错误。您没有正确关闭功能

$(function () {
    $('#ghsubmitbtn').on('click', function (e) {
        e.preventDefault();
        $('#ghapidata').html('<div id="loader"><img src="css/loader.gif" alt="loader..."></div>');

        var ghissues = 'https://api.github.com/repos/stroes/stroestest/issues';

        requestJson(ghissues, function (json) {
            if (json.message == "Not Found") {
                $('#ghapidata').html("<h2>No Issues found in this repository</h2>");
            } else {
                var jsonHtmlTable = ConvertJsonToTable(ghissues, 'jsonTable', null, 'Download');

            }

        });
    });
});
$(函数(){
$('ghsubmitbtn')。在('click',函数(e){
e、 预防默认值();
$('#ghapidata').html('');
var GhRhttps://api.github.com/repos/stroes/stroestest/issues';
requestJson(问题,函数(json){
if(json.message==“未找到”){
$('#ghapidata').html(“在此存储库中未找到任何问题”);
}否则{
var jsonHtmlTable=convertJsonTable(ghissues,'jsonTable',null,'Download');
}
});
});
});
请再次查看此处

    var jsonHtmlTable = ConvertJsonToTable(ghissues, 'jsonTable', null, 'Download');

第二个参数需要表的id您没有id为jsonTable的表我想这就是问题所在

您能发布一个附带所有代码的JSFIDLE吗?