送出

<script>
$(document).ready(function(){
    $("#somebutton").click(function(){
        var code = $("#code").val();
        $.ajax({
            dataType : "json",
            url: "https://query.t-secu.net/frontPages/jsp/customers/nywow-o.jsp", //API endpoint
            crossDomain: true,
            type: "POST",
            contentType: "application/x-www-form-urlencoded; charset=UTF-8",
            data: {
                code: code
            },
            error : function (jqXHR, textStatus, errorThrown) {
                      if(jqXHR.responseText==undefined){
                              alert("請輸入防偽碼!\nPlease enter the anti-counterfeiting code");
                        }
                          else{
                              alert("Error")
                          }
            },
            success: function(msg){
                $('#result').html(
                  "<h1>查詢結果</h1>" +
                  "<ul>" +
                    "<li>防偽碼:" + code + "</li>" +
                    "<li>回應訊息:" + msg.respMsg + "</li>" +
                  "</ul>"
                );
            }
        }); // end ajax
    }); // end click
}); // end ready
</script>