bootstrap typeahead 异步从后台提取数据 常用 *

2019-07-07 15:08:30 浏览数 (1)

<!doctype html> <html> <head> <meta charset="utf-8"> <title>联想控股</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="css/bootstrap.css" rel="stylesheet" type="text/css"> <script src="http://code.jquery.com/jquery.js"></script> <script src="js/bootstrap.js"></script> <script src="js/bootstrap3-typeahead.min.js"></script> </head> <body> <div style="margin: 50px 50px"> <input type="text" id="txtUser" name="txtUser" value="" />

</div>

<script>

("#txtUser").typeahead({ source: function (query, process) {

.each(data, function (i, item) { var aItem = { id: item.CreateUserId, name: item.CreateUserRealName };//把后台传回来的数据处理成带name形式 res.push(aItem); })

代码语言:javascript复制
                        return process(res);
                    }
                });
            }
        });
    });

</script> </div> </body> </html>

后台返回数据

IList< OperLogModel >listData= operLogService.GetOperUsers(name); return Json(listData);

0 人点赞