加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Ajax($.getJSON使用实例)

发布时间:2020-12-15 21:02:19 所属栏目:百科 来源:网络整理
导读:script type="text/javascript" function pageIndexChanged() { var url = "/OrderList/Lists"; var where = ""; @*location.href = "@this.Url.Action("List")?pageindex=" + $("#pager").pager("pageindex") + "pagesize=" + $("#pager").pager("pagesize"
<script type="text/javascript">
    function pageIndexChanged() {
        var url = "/OrderList/Lists";
        var where = "";
        @*location.href = "@this.Url.Action("List")?pageindex=" + $("#pager").pager("pageindex") + "&pagesize=" + $("#pager").pager("pagesize") + "&where=" + escape(where);*@
        var pageindex = $("#pager").pager("pageindex");
        var pagesize = $("#pager").pager("pagesize");
        where = escape(where);
        $.getJSON(url,{ where: where,pageindex: pageindex,pagesize: pagesize },function (data) {
           
            alert(data.total);
            alert(data.rows[0].Order.OrderID);
            
            alert(data.PageIndex);
            alert(data.PageSize);

        });
    }

    $(function () {
        $("#order-details-search").click(function () {
            $(".detail-search").show(100);
        });

        $("#detail_search_cancle").click(function () {
            $(".detail-search").hide(100);
        })
    });
</script>
var cache = {};
                    var data;
                    $("#seachers").autocomplete(
                        {
                            source: function (request,response) {
                                var term = request.term;
                                if (term in cache) {
                                    data = cache[term];
                                    response($.map(data.NameList,function (item) {
                                        return { label: item.ProjectName };
                                    }));
                                } else {
                                    $.ajax({
                                        url: "@this.Url.Action("AutoGet","Project")",dateType: "jsonp",data: {
                                            top: 10,key: request.term
                                        },success: function (data) {
                                            if (data.NameList.length) {
                                                cache[term] = data;
                                                response($.map(data.NameList,function (item) {
                                                    return { label: item.ProjectName };
                                                }));
                                            }
                                        }
                                    });
                                }
                            },minLength: 1,autoFocus: false,delay: 500
                        });

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读