首页 > 代码库 > MVC-AJAX-JSON

MVC-AJAX-JSON

前台:

 function get_page_count() {
        $.ajax({
            type: "GET",
            data: { typeId: $("#select").val(), keyWord: $("#key_word").val() }, 
            cache: false,
            url: ‘/ResourceProvie/get_pageCount‘,
            dataType: "json",
            success: function (result) {

                alert("a" + result);
            },
            error: function (result) {
                alert(result);
                alert("b");
            }
        }

        );
后台:
 public ActionResult get_pageCount(int? typeId, string keyWord)
        {
            int pageCount = 0;
           
             _resourceRepository.get_pageCount(typeId, keyWord, ref pageCount);
             Hashtable hash = new Hashtable();
             hash["pageCount"] = pageCount;
             return Json(hash,"text/html;charset=UTF-8");
        }

MVC-AJAX-JSON