我在搜索某物时遇到问题,并且按下搜索按钮时它没有显示输出。当jquery ajax搜索结果如何获取结果。我正在使用inteilj
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>mainpage</title>
<script src="jquery-3.3.1.min.js"></script>
</head>
<body>
<form>
<input id="mysearch"text="text" placeholder="Search...">
<button id="search" >Search </button>
</form>
<ul id="movies">
<li id="result"></li>
</ul>
<script type="application/javascript" >
$(document).ready(function(){
$('#search').onkeypress(function(){
$.ajax({
url: 'http://localhost:8080/api/movies',
method: 'GET',
dataType: 'json',
success: function(data){
$.each(data, function(index, val){
$('#movies').append($('<li>').text('title: ' + val.title + ', year: ' + val.year ));
});
}
});
});
});
</script>
</body>
</html>
答案 0 :(得分:0)
使用 onClick 事件监听器,使您的脚本成为
float opacity = 0.5f; // between 0.0f and 1.0f
myFrame.setOpacity(opacity);
答案 1 :(得分:0)
您的事件应该是.keypress
而不是.onkeypress