I'm trying to create a URL that passes an input text into a query string for an AJAX call. In the console, I can see that I'm capturing the inputted text as a string, but it's not passing into the URL and It's returning an empty object.
<form action="" method="GET">
<input type="text" id="movie-title" placeholder="Enter a movie title">
<input type="submit" id="sbmt-movie">
</form>
$("#sbmt-movie").click(function(){
var movie = $("#movie-title").val().toLowerCase();
console.log("the movie title is " + movie);
var url = "https://api.themoviedb.org/3/search/movie?query=" + encodeURIComponent(url) + "&api_key=9b97ec8f92587c3e9a6a21e280bceba5";
$.ajax ({
url: url,
dataType: "json",
success: function (data) {
console.log(data);
var list = data.list;
}
}); //close .ajax
});
This is the information that I'm seeing in console:
XHR finished loading: GET "https://api.themoviedb.org/3/search/movie?query=undefined&api_key=9b97ec8f92587c3e9a6a21e280bceba5".
Object {page: 1, results: Array[0], total_results: 0, total_pages: 1}