<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div>
<form id="myform">
<div class="input-field">
<input type="search" id="books">
<label for="search">Search books</label>
</div>
<button class="btn red"></button>
</form>
</div>
<div class="result">
</div>
<script src="https://cdn.bootcss.com/jquery/3.3.0/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/materialize/1.0.0-beta/js/materialize.min.js"></script>
<script src="index.js"></script>
</body>
</html>
index.js:
$(document).ready(function() {
console.log("jQuery sucessful")
$("-sharpmyform").submit(function() {
var search = $("-sharpbooks").val();
console.log(search);
if(search === "") {
alert("Please enter something");
}else {
var url = "";
var img = "";
var title = "";
var author = "";
$.get("https://www.googleapis.com/books/v1/volumes?q=" + search,function(res) {
console.log(res);
});
}
});
return false;
});