I want to display a list of all movies shown when i search for a specific movie.Right now it only lists them like array.I want to see the title
, poster
, year
its filmed etc This is my code.Its my first time working with api. Thanks to all who will reply.
$(document).ready(function() {
$('#formSubmit').click(function(e) {
let txtSearch = $('#txtSearch').val();
getMovies(txtSearch);
e.preventDefault();
});
});
function getMovies(txtSearch) {
$.get('http://www.omdbapi.com/?apikey=KEY&s=' + txtSearch, function(txtSearch) {
console.log(txtSearch);
//This is where the request goes//
});
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<form action="" method="GET">
<div class="row">
<div class="col-lg-6 col-xs-6 col-md-4 col-lg-offset-3" id="searchForm">
<p class="header">Search movie by title</p>
<div class="input-group">
<input type="text" class="form-control" placeholder="Enter movie name" id="txtSearch" />
<div class="input-group-btn">
<button class="btn btn-primary" type="submit" id="formSubmit">
<span class="glyphicon glyphicon-search"></span>
</button>
</div>
</div>
</div>
</div>
</form>
</div>