AJAX跳转页面

来源:互联网 发布:西方八一军演 知乎 编辑:程序博客网 时间:2024/05/21 21:18

1.绑定html页面

   <input type="button" onclick=" search11By22" id="searchBtn" style=" background:url(/Content/images/button/btn-gia-search.gif); border:none; width:44px;height:23px; padding:0;"/>

2.定义js函数

 var search11By22 = function () {            $.ajax({            url: "/Search/Ajax22",            cache: false,            type: 'POST',            dataType: 'html',            data: ({ a:$(".searchBox").val()}),            success: function (data, textStatus, jqXHR) {                $("#searchResult").html(data);            },            error: function (jqXHR, textStatus, errorThrown) {              //alert($("#searchResult").val());            }        });    };

3.Controller端进行业务逻辑

   string a=string.Empty;            if (!String.IsNullOrEmpty(Request["a"]))            {                a = Request["a"];            }            long Id = QueryService.getCertficationDiamondId(a);            IList<b> b = QueryService.c(diamondId);            ViewData["eee"] = b;            ViewData["totalCount"] = "1";            ViewData["totalPages"] = "1";            ViewData["pageNum"] = "1";            return View();

4.返给页面