Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

AJAX Questions with Correct Answers 2024/2025, Exams of Computer Communication Systems

A comprehensive set of ajax-related questions and their corresponding answers. It provides a detailed overview of various ajax concepts, including how a user interacts with a server, updating web page content without loading a new page, the use of different programming languages for ajax, the purpose of xml and json, managing ajax requests, the differences between get and post requests, the structure of ajax responses, and the use of ajax libraries like jquery. The document also covers topics such as cross-domain policies, web proxies, http status codes, and the integration of ajax with third-party apis. This resource would be highly valuable for students and professionals looking to deepen their understanding of ajax and its practical applications.

Typology: Exams

2023/2024

Available from 10/22/2024

Fortis-In-Re
Fortis-In-Re 🇺🇸

1

(1)

2.3K documents

1 / 18

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
AJAX QUESTIONS WITH CORRECT ANSWERS 2024/2025
What does AJAX stand for? - ANS-✔✔Asynchronous JavaScript And XML
Explain in proper term how a user interacts with a server - ANS-✔✔The process of asking a server for
information is technically called making a request of the server. And when the server sends back its
answer, that's called a response. Keep those two words in mind.
What does AJAX let you do? - ANS-✔✔Update content on a web page without loading a new web page.
Which server-side languages does AJAX work with?
A Ruby
B PHP
C Python
D Cold Fusion
E All of the above - ANS-✔✔All of the above
When a server answers an AJAX request it sends back a... - ANS-✔✔response
You use AJAX to communicate with a web server by sending it a ... - ANS-✔✔request
What does XML stand for? - ANS-✔✔Extensible Markup Language.
What are the 4 steps of an AJAX request? - ANS-✔✔1. Create and XMLHTTP Request Object
2. Create a callback function
3. Open a request
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12

Partial preview of the text

Download AJAX Questions with Correct Answers 2024/2025 and more Exams Computer Communication Systems in PDF only on Docsity!

AJAX QUESTIONS WITH CORRECT ANSWERS 2024/

What does AJAX stand for? - ANS-✔✔Asynchronous JavaScript And XML

Explain in proper term how a user interacts with a server - ANS-✔✔The process of asking a server for information is technically called making a request of the server. And when the server sends back its answer, that's called a response. Keep those two words in mind.

What does AJAX let you do? - ANS-✔✔Update content on a web page without loading a new web page.

Which server-side languages does AJAX work with?

A Ruby

B PHP

C Python

D Cold Fusion

E All of the above - ANS-✔✔All of the above

When a server answers an AJAX request it sends back a... - ANS-✔✔response

You use AJAX to communicate with a web server by sending it a ... - ANS-✔✔request

What does XML stand for? - ANS-✔✔Extensible Markup Language.

What are the 4 steps of an AJAX request? - ANS-✔✔1. Create and XMLHTTP Request Object

  1. Create a callback function
  2. Open a request
  1. Send a request

What is one characteristic of "asynchronous" AJAX requests? - ANS-✔✔Callbacks for multiple AJAX requests may not run in the order the requests were sent. Servers may take longer to respond to certain requests, so callbacks run in the order in which the responses return.

What type of JavaScript object do web browsers use to manage AJAX requests? - ANS-✔✔ XMLHttpRequest Object

The term "XMLHttpRequest object" is often shortened to which of the following? - ANS-✔✔XHR Object

AJAX is the W3C's (World Wide Web Consortium's) official term for an XMLHttpRequest. - ANS-✔✔ False

What would you use GET or POST for - ANS-✔✔You'll use GET if you want to send a request for data, a request for data and POST if you're sending the data (that should be saved). Like information from a form, for the server to save in the database.

In the app.js file, create a variable named request and assign it a new XMLHttpRequest object. - ANS-✔ ✔var request = new XMLHttpRequest();

In app.js, we've added an AJAX callback function. You need to complete the request. Add the code to open the AJAX request using the GET method and pointing to the 'footer.html' file.

var request = new XMLHttpRequest();

request.onreadystatechange = function () {

if (request.readyState === 4) {

document.getElementById("footer").innerHTML = request.responseText;

Which of these is a difference between GET and POST? - ANS-✔✔POST sends its data in the "body" of the request. GET sends data in the URL.

When should you use the POST HTTP method with AJAX? - ANS-✔✔

Which of these is an example of a valid query string?

A http://server.com/page.php

B http://server.com/page.php?name=Johnny Depp&movie=Pirates of the Caribbean: A Dead Man's Chest

C http://server.com/name=Johnny Depp&movie=Pirates of the Caribbean: A Dead Man's Chest

D http://server.com/page.php?name=Johnny+Depp&movie=Pirates+of+the+Caribbean%3A+Dead+Man% 27s+Chest - ANS-✔✔D

http://server.com/page.php?name=Johnny+Depp&movie=Pirates+of+the+Caribbean%3A+Dead+Man% 27s+Chest

When should you use the POST HTTP method with AJAX?

A Everytime you submit information from a form.

B When you want to send data that the web server should store in a database.

C When you want to send more than 2083 characters of data to the web server.

D All of the above.

E Answers B and C only. - ANS-✔✔E

Answers B and C only.

Which of these is NOT a common AJAX response format?

A HTML

B Binary Files

C Plain text

D XML

E JSON - ANS-✔✔Binary Files: You can receive binary files -- like images -- using AJAX, but plain text formats like JSON, XML, and HTML are more common.

HTML and XML both use tags to mark up information. - ANS-✔✔True

XML is the preferred format for AJAX responses because XML is the easiest format for JavaScript to work with. - ANS-✔✔XML is the preferred format for AJAX responses because XML is the easiest format for JavaScript to work with.

Define JSON - ANS-✔✔JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate.

Define JSONP - ANS-✔✔JSONP (means "JSON with Padding") is a method commonly used to bypass the cross-domain policies in web browsers (you are not allowed to make AJAX requests to a webpage perceived to be on a different server by the browser). JSON and JSONP behave differently on both the client and the server.

What does CORS stand for? - ANS-✔✔Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources (e.g. fonts) on a web page to be requested from another domain outside the domain from which the resource originated.

What is the value of an XMLHttpRequest object's readyState when the browser has received all of the data from the server? - ANS-✔✔ 4

Which of the following correctly creates an XHR object?

A var request = new xhrObject();

B var xhr = new XMLHttpRequestObject();

C var xhr = XMLHttpRequest();

D var xhr;

E var request = new XMLHttpRequest(); - ANS-✔✔E

var request = new XMLHttpRequest();

A variable named xhr contains an XMLHttpRequest Object. Which of these sends the AJAX request to the server?

A xhr.post();

B xhr.send();

C xhr.XMLHttpRequest().send();

D xhr();

E xhr.sendRequest(); - ANS-✔✔B xhr.send();

Which of the following IS TRUE about JSON properties?

A Property names must be capitalized

B Property names must start with op_

C Property names are separated from property values by a comma

D Property names must be quoted using double quotes

E None of the above - ANS-✔✔D Property names must be quoted using double quotes

Write a correctly formatted JSON property name / value pair? - ANS-✔✔"property": "value"

Which of the following is valid JSON?

Choose the correct answer below:

A

[

"AJAX Basics",

"jQuery Basics"

]

B

{

"course1" : "AJAX Basics",

"course2" : "jQuery Basics"

}

C "AJAX Basics"

D

[

{

"course" : "AJAX Basics"

},

{

var word = "Treehouse";

alert( typeof word); - ANS-✔✔string

What does CDN stand for? - ANS-✔✔Content Delivery Network. A CDN is used to deliver content from a third party server.

What is jQuery? - ANS-✔✔A popular JavaScript library that simplifies making AJAX requests.

What does this code do:

$('#ajax').load('sidebar.html'); - ANS-✔✔It loads the contents of the sidebar.html file into an HTML element with the ID of "ajax."

The .load() method is a quick way to insert HTML content into an element on a page using AJAX.

jQuery passes the data from the server response to the callback function of $.get(). This is the same as which of the following XMLHTTPRequest object properties? - ANS-✔✔The responseText property

jQuery's $.get() method accepts three arguments. What order do they go in? - ANS-✔✔1. URL

  1. Data for the server
  2. Callback function to process the server response

What is the difference between jQuery's .load() AJAX method and jQuery's other shorthand AJAX methods? - ANS-✔✔The .load() method must be chained onto a jQuery selection. For example, $('#element').load('page.html');

Which of the following is NOT a jQuery AJAX shorthand method?

A .load()

B $.get()

C $.post()

D $.getJSON()

E All of these are shorthand AJAX methods - ANS-✔✔E All of these are shorthand AJAX methods

You've got the $.get() method and first argument in place. The second argument to the $.get() method is a callback function. Pass an anonymous function as the second argument to the method. Don't forget to set a parameter for that function to catch the server's incoming response.

Add to : $.get("footer.html"); - ANS-✔✔$.get("footer.html", function (response) {});

Complete this code to retrieve a form's "action" attribute and store it in the variable url:

var url = $('form').__("action"); - ANS-✔✔attr =

var url = $('form').attr("action");

What does jQuery's preventDefault() method do? - ANS-✔✔It's used with an event object to prevent the browser from responding normally to an event -- for example, it prevents a form from being submitted, or loading a new web page when a link is clicked.

What does jQuery's serialize() method do? - ANS-✔✔Creates a text string with standard URL-encoded notation of fields in an HTML form.

Complete the code below to add a submit event handler to a form:

A

$('#sidebar').ajax("sidebar.html", function (response) {

$('#sidebar').html(response);

B

$.ajax("sidebar.html", {

success : function(response) {

$('#sidebar').html(response);

}

}); - ANS-✔✔B

$.ajax("sidebar.html", {

success : function(response) {

$('#sidebar').html(response);

}

});

What two parameters does jQuery's $.ajax() method accept? - ANS-✔✔1. A URL

  1. A JavaScript object containing settings that control how the AJAX request is made

What is jQuery's low-level AJAX method -- the one all the shorthand methods are built on? - ANS-✔✔ $.ajax()

What is the jQuery method for handling errors in an AJAX response? - ANS-✔✔.fail()

In which of the following situations does jQuery's .fail() method NOT work? - ANS-✔✔When using the .load() method.

AND

When making requests to another site.

The callback function for jQuery's .fail() method receives a jQuery XHR object as a parameter. What property of the jQuery XHR object provides the response's HTTP status code? - ANS-✔✔status

The callback function for jQuery's .fail() method receives a jQuery XHR object as a parameter. What property of the jQuery XHR object provides a text description of the response's status code? - ANS-✔✔ statusText

An API lets you connect to a third-party web site like YouTube or Twitter and request content. - ANS-✔ ✔True

Which of the following programming languages can be used to talk to third-party APIs?

A Ruby

B PHP

C Python

D JavaScript

E All of the above - ANS-✔✔E All of the above

What does API stand for? - ANS-✔✔Application Programming Interface

What is an API key for? - ANS-✔✔Lets a web developer connect with a third party API like Google Maps.

Lets a web site limit access to its API.

What does this code do?

$(document).ready(function () {

}); - ANS-✔✔It waits until the HTML for the page has loaded before running the JavaScript code placed inside it.

Complete the code below to remove the class "selected" from all button elements.

$("button").____("selected"); - ANS-✔✔removeClass

$("button").removeClass("selected");

Which of jQuery's AJAX methods can you use to make a JSONP request? - ANS-✔✔$.getJSON()

You can send Flickr's public photo feed a property named "format". What does the "format" property do? - ANS-✔✔It lets you specify the format for the feed, for example an XML or JSON format.

What 3 parameters does jQuery's $.getJSON() method accept? - ANS-✔✔1. URL

  1. data
  2. success

Finish the code below to retrieve the text inside an HTML element with the ID of "button" and store it in the variable "animal":

var animal = $('#button')._____; - ANS-✔✔text()

var animal = $('#button').text();

You can send Flickr's public photo feed a property named "tags". What does the "tags" property do? - ANS-✔✔It lets you search for photos that match a particular keyword.

Assume you have the following JavaScript object:

var contact = {

name : "Jill",

phone: "510-555-1212"

};

Finish the code below to display the object's "name" property in an alert box:

alert(_______); - ANS-✔✔contact.name

alert(contact.name);

Finish the code below to insert the contents of the variable "sidebarHTML" into an HTML element with the ID of "sidebar". Make sure you insert this content as HTML using jQuery.

$('#sidebar').____________; - ANS-✔✔html(sidebarHTML)