我想从用户那里获取输入,然后在Google图书中使用输入,然后在单独的页面中显示结果,如何使用JQuery或PHP做到这一点?

时间:2019-05-12 09:11:36

标签: php jquery html api google-books

我有一个HTML页面,该页面具有一个文本框,可以接受用户的输入。输入将被带到JQuery并用于搜索Google Books API,然后结果应显示在单独的页面中,但是我无法在其他页面中打印出来,该怎么做?

$(document).ready(function() {
  $("#searchBookForm").submit(function(event) {
    // event.preventDefault();
    var search = $("#searchISBN").val();
    if (search == '') {
      alert("Please enter an ISBN");
    } else {
      $.get("https://www.googleapis.com/books/v1/volumes?q=" + search, function(response) {
        console.log(response);
      });
    }
  });
  return false;
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form method="get" id="searchBookForm">
  <div class="form-row justify-content-center">
    <div class="col-3 col-lg-offset-4">
      <input id="searchISBN" type="search" class="form-control" placeholder="Type in ISBN...">
    </div>
    <div class="col-2">
      <button type="submit" id="submitSearch" class="btn btn-danger">Submit</button>
    </div>
  </div>
</form>

0 个答案:

没有答案