JQuery Flashcards

Defining Code

1
Q
Define the purpose of this code:
$.ajax({
        url: queryURL,
        method: "GET"
      })
A

Creates AJAX call for the specific movie button being clicked

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
Define the purpose of this code:
var movieDiv = $("<div>");</div>
A

Creates a div to hold the movie

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Define the purpose of this code:
var ratedPara = $(“<p>”);
ratedPara.text(rated);</p>

A

Creates an element to have the rating displayed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
Define the purpose of this code:
var rated = response.Rated;
A

Retrieves the Rating Data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Define the purpose of this code:

movieDiv.append(ratedPara);

A

Displays the rating

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
Define the purpose of this code:
var released = response.Year;
A

Retrieves the release year

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Define the purpose of this code:
var releasedPara = $(“<p>”);
releasedPara.text(released);</p>

A

Creates an element to hold the release year

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Define the purpose of this code:

movieDiv.append(releasedPara);

A

Displays the release year

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Define the purpose of this code:

$(“#moviesview”).prepend(movieDiv);

A

prepending movieDiv to an html element with the id of movie-view

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
Define the purpose of this code:
var catImage = $("<img>");
A

setting a variable to store an img html element

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Define the purpose of this code:

catImage.attr(“src”, imageUrl); catImage.attr(“alt”, “cat image”);

A

setting the attributes of the img tag

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
Define the purpose of this code:
var imageUrl = response.data.image_original_url;
A

setting a variable to store data retrieved from an API

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
Define the purpose of this code:
var queryURL = "https://api.giphy.com/v1/gifs/random?api_key=dc6zaTOxFJmzC&amp;tag=cats";
A

setting a variable to store the getting the cat gif from the Giphy API

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Complete the syntax for this code:
$.ajax({
url: queryURL,

A

$.ajax({
url: queryURL,
method: “GET”
})

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Define the purpose of this code:

$(“#list-names”).append(“<li>”);</li>

A

appending an list element to an element with the id of list-names.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
Define the purpose of this code:
var userInput = $("#input").val();
A

storing the value of an element with the id of input into the variable of userInput.