Mv添加显示

<script>
    $(function () {
        show();
    });
    function show() {
        $.ajax({
            url: "http://localhost:61678/api/search",
            data: null,
            dataType: "json",
            type: "get",
            success: function (result) {
                ShowList(result);
            }
        })
    }
    function ShowList(result) {
        var str = "";
        $.each(result,function (i, n) {
           
            str += "<tr><td>" + n.ID + "</td>";
            str += "<td>" + n.ActivityName + "</td>";
            str += "<td>" + n.Name + "</td>";
            str += "<td>" + n.Common + "</td>";
            str += "<td>" + n.Num + "</td>";
            str += "<td>" + n.Balance + "</td>";
            str += "<td>" + n.Number + "</td>";
            str += "<td>" + n.BalanceNum + "</td>";
            str += "<td>" + n.State + "</td>";
            str += "<td>" + n.Type + "</td>";
            str += "<td>" + n.Remark + "</td>";
            str += "<td>" + n.CreateTime + "</td></tr>";
           
        });
        $("#tb tr:gt(0)").empty();
        $("#tb").append(str);
    }
</script>
////////*****///////
<script>
    $(function () {
        Type();
        State();
        $("#Save").click(function () {
            var obj = {};
            obj.Name = $("#Name").val();
            obj.Type = $("#TName option:selected").val();
            obj.Num = $("#Num").val();
            obj.Balance = $("#Balance").val();
            obj.Number = $("#Number").val();
            obj.BalanceNum = $("#BalanceNum").val();
            obj.Common = $("#Common").val();
            obj.State = $("#SName option:selected").val();
            $.ajax({
                url: "http://localhost:61678/api/Append", //要处理的页面
                data: obj,  //要传过去的数据
                type: "POST",  //提交方式
                dataType: "TEXT", //返回的数据类型,TEXT字符串 JSON返回JSON XML返回XML;dataType中T要大写!!
                success: function (res) { //回调函数,data为形参,是从login-cl.php页面返回的值
                    if (res > 0) {
                        alert("添加成功");
                        location.href = "http://localhost:63528/Red/Show";
                    }
                    else {
                        alert("添加失败");
                    }
                }
            });
        });
    });
    //反填下拉框
    function Type() {
        $.ajax({
            url: "http://localhost:61678/api/type",
            dataType: "json",
            type: "get",
            success: function (result) {
                $(result).each(function (i, n) {
                    $("#TName").append("<option value='" + n.TID + "'>" + n.TName + "</option>");
                })
            }
        })
    };
    function State() {
        $.ajax({
            url: "http://localhost:61678/api/state",
            dataType: "json",
            type: "get",
            success: function (result) {
              
                $(result).each(function (i, n) {
                    $("#SName").append("<option value='" + n.SID + "'>" + n.SName + "</option>");
                })
            }

        })
    };
</script>
posted @ 2020-07-02 11:00  我们好像在那见过  阅读(94)  评论(0编辑  收藏  举报