JavaScript Questions & Answers – Scripted HTTP

This set of Javascript Multiple Choice Questions & Answers (MCQs) focuses on “Scripted HTTP”.

1. Which property helps to initiate the HTTP requests?
a) request
b) location
c) send
d) write
View Answer

Answer: b
Explanation: It is possible for JavaScript code to script HTTP, however. HTTP requests are initiated when a script sets the location property of a window object or calls the submit() method of a form object. The location object is part of the window object and is accessed through the window.location property.

2. Which method is an alternative of the property location of a window object?
a) submit()
b) locate()
c) load()
d) write()
View Answer

Answer: a
Explanation: HTTP requests are initiated when a script sets the location property of a window object or calls the submit() method of a form object. In both cases, the browser loads a new page.

3. Which of the following uses scripted HTTP?
a) XML
b) HTML
c) Ajax
d) CSS
View Answer

Answer: c
Explanation: AJAX stands for Asynchronous JavaScript And XML. The key feature of an Ajax application is that it uses scripted HTTP to initiate data exchange with a web server without causing pages to reload.
advertisement
advertisement

4. Which of the below is a liberal reverse of Ajax?
a) HTTP
b) HTML
c) XML
d) Comet
View Answer

Answer: d
Explanation: Comet is the reverse of Ajax: in Comet, it is the web server that initiates the communication, asynchronously sending messages to the client. The big advantage of Comet is that each client always has a communication link open to the server.

5. The other name for Comet is _____________
a) Server Push
b) Ajax Push
c) HTTP Streaming
d) All of the mentioned
View Answer

Answer: d
Explanation: Comet is a web application model where a request is sent to the server and kept alive for a long time, until a time-out or a server event occurs. Other names for Comet include “Server Push”, “Ajax Push”, “HTTP Streaming”.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. Which is the element that has a src property to initiate HTTP GET request?
a) img
b) iframe
c) script
d) both img and script
View Answer

Answer: d
Explanation: Both img and script contains the src property that can be set to initiate an HTTP GET request. The src property sets or returns the value of the src attribute of an image.The required src attribute specifies the URL of an image.

7. XMLHttpRequest is a ____________
a) Object
b) Class
c) Both Object and Class
d) Array
View Answer

Answer: c
Explanation: XMLHttpRequest is both an object and a class. The XMLHttpRequest object can be used to request data from a web server.
advertisement

8. Which of the following are the features of an HTTP request?
a) URL being requested
b) Optional request body
c) Optional set of request headers
d) All of the mentioned
View Answer

Answer: d
Explanation: An HTTP request consists of four parts :

  1. the HTTP request method or “verb”
  2. the URL being requested
  3. an optional set of request headers, which may include authentication information
  4. an optional request body

9. Which of the following is a feature of the HTTP response?
a) Mandatory response body
b) Optional response body
c) URL being released
d) Optional set of response headers
View Answer

Answer: a
Explanation: The HTTP response sent by a server has three parts :

  1. a numeric and textual status code that indicates the success or failure of the request
  2. a set of response headers
  3. the response body
advertisement

10. Which is the appropriate code to begin a HTTP GET request?
a) request.open(“GET”,”data”);
b) request.open(GET,”data.csv”);
c) request.open(“GET”,”data.csv”);
d) request.open(“GET”);
View Answer

Answer: c
Explanation: The code that begins a HTTP GET request for the contents of the specified URL is

request.open("GET","data.csv");

To send a request to a server open() and send() methods of the XMLHttpRequest object are used.

Sanfoundry Global Education & Learning Series – Javascript Programming.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.