私はこのコードを持っています:
<div id='mainTop'>                 
    <span></span>
    <button><h3>Search</h3></button>
    <div class='inputField'><input type='text' name='search' size=45></div>
</div>
<script>
    function showPage(page,key)    {   
        if(!key)
            $.get("showPage.php?page="+page,function(data){
                /**
                 *    Insert HTML result from PHP file
                 *    Then edit table color
                 *    In the end call function buttonPage()
                 */
                $("#mainTable").html(data);
                $("#mainTable tr:odd td").css("background-color","#e3f0ad");
                buttonPage(page);
            });
        else
            $.get("showPage.php?page="+page+"&key="+key,function(data){
                $("#mainTable").html(data);
                $("#mainTable tr:odd td").css("background-color","#e3f0ad");
                buttonPage(page,key);
            });
    }
    $("#mainTop button").click(function(){
        key= $("#mainTop input").val();
        if(!key)
            showPage(1,key);
    });
</script>
私が欲しいのは、データベースを検索するための入力フィールドとボタンを用意することです。
キーがnullの場合、キーパラメータをphpファイルに渡さず、データベースを出力します。
キーがnullでない場合は、キーパラメータをphpファイルに渡し、そのキーを使用してデータベースを検索します。
phpファイルを単独で実行しようとしましたが、ボタンをクリックしても何も起こらないので、スクリプトに問題があると思います。誰かが私を助けてくれますか?