<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<input type="text" name="name">
<h1></h1>
<h2></h2>
<img src="" alt="" class="avatar">
<img src="" alt="" class="bg">
<p></p>
<script src="js/jquery.js"></script>
<script>
$(function () {
// $.get('https://autumnfish.cn/api/hero/simple', {name: '亚索'}, function(data){
// console.log(data);
// });
// $.post('https://autumnfish.cn/api/user/register', {username: 'admin'}, function(data){
// console.log(data);
// });
$('input[name=name]').keyup(function (e) {
if (e.keyCode === 13) {
var v = $(this).val();
console.log(v);
$.get('https://autumnfish.cn/api/hero/info?name=' + v, function (data) {
// console.log(data);
$('h1').html(data.name);
$('h2').html(data.title);
$('img.avatar').attr('src', data.icon);
$('img.bg').attr('src', data.bg);
$('p').html(data.story);
});
}
});
});
</script>
</body>
</html>
在搜索框内添加英雄联盟的英雄的名字后按enter键