JQuery Flashcards
Defining Code
Define the purpose of this code: $.ajax({ url: queryURL, method: "GET" })
Creates AJAX call for the specific movie button being clicked
Define the purpose of this code: var movieDiv = $("<div>");</div>
Creates a div to hold the movie
Define the purpose of this code:
var ratedPara = $(“<p>”);
ratedPara.text(rated);</p>
Creates an element to have the rating displayed
Define the purpose of this code: var rated = response.Rated;
Retrieves the Rating Data
Define the purpose of this code:
movieDiv.append(ratedPara);
Displays the rating
Define the purpose of this code: var released = response.Year;
Retrieves the release year
Define the purpose of this code:
var releasedPara = $(“<p>”);
releasedPara.text(released);</p>
Creates an element to hold the release year
Define the purpose of this code:
movieDiv.append(releasedPara);
Displays the release year
Define the purpose of this code:
$(“#moviesview”).prepend(movieDiv);
prepending movieDiv to an html element with the id of movie-view
Define the purpose of this code: var catImage = $("<img>");
setting a variable to store an img html element
Define the purpose of this code:
catImage.attr(“src”, imageUrl); catImage.attr(“alt”, “cat image”);
setting the attributes of the img tag
Define the purpose of this code: var imageUrl = response.data.image_original_url;
setting a variable to store data retrieved from an API
Define the purpose of this code: var queryURL = "https://api.giphy.com/v1/gifs/random?api_key=dc6zaTOxFJmzC&tag=cats";
setting a variable to store the getting the cat gif from the Giphy API
Complete the syntax for this code:
$.ajax({
url: queryURL,
$.ajax({
url: queryURL,
method: “GET”
})
Define the purpose of this code:
$(“#list-names”).append(“<li>”);</li>
appending an list element to an element with the id of list-names.