These Ajax multiple-choice questions and their answers will help you strengthen your grip on the subject of Ajax. You can prepare for an upcoming exam or job interview with these Ajax MCQs.
So scroll down and start answering.
A. Asynchronous Binary Transfer Protocol, ABTP
B. Hypertext Transfer Protocol, HTTP
C. AJAX Object Protocol, AOP
D. Advanced Server Protocol, ASP
A. GET, POST and PUT
B. GET, POST, and DELETE
C. GET and POST
D. GET, POST, PUT, and DELETE
A. var xhr = navigator.XMLHTTPRequest();
B. var xhr = new XMLHTTPRequest();
C. var xhr = new XMLHttpRequest();
D. var xhr = window.XmlHTTPRequest();
A. No, it is not possible
B. Yes, it is possible. setRequestHeader() method of XMLHttpRequest object can be used to add a custom HTTP header
C. Yes, it is possible. Custom HTTP header can be added while initializing a request with init() method
D. Yes, it is possible. Custom HTTP header can be added while initializing a request with open() method
A. .statusText is the more widely supported of the two across browsers
B. .status returns a numeric-only code instead of the full HTTP response, which can be found in .statusText
C. .statusText is not a valid attribute of the XMLHttpRequest object
D. .status is read-only, while .statusText can be modified
A. To allow cross-domain data transfer
B. To check server-side functionality before executing client-side code
C. To allow offline functionality in Ajax-driven web applications
D. To keep a server connection open for two-way communication
A. Domain name, protocol, and port
B. IP subnet
C. Second-level domain only
D. Full domain name
A. There is no effective method
B. < or > in the URL
C. history.pushState()
D. window.location()
A. New browser chrome events: onbackbuttonpressed and onforwardbuttonpressed.
B. The history API with pushState, replaceState and history events.
C. The storage API with css3 full page state saving.
D. The version API that allows versioning page interactions.
A. It is not an acronym
B. binned large ordinal byte
C. binary large object
D. bytes left over from bitstream
A. Events and callbacks
B. Multi-threaded operations
C. Deferrals and promises
A. A Java plugin must be installed and enabled.
B. Cookies must be enabled.
C. A Flash plugin must be installed
D. JavaScript must be enabled.
E. Private browsing must be enabled.
A. There is no advantage
B. Fewer HTTP requests and smaller loaded resources
C. Better cross-browser compatibility and faster speed of development
A. It makes pages more easily bookmarked, shared and navigated by users using standard browser controls.
B. It makes web applications more easily crawlable by search engines like Google, Yahoo and Bing.
C. It makes it easier to create accessible (usable by people of all abilities and disabilities) web pages
D. It allows web applications to send asynchronous data requests to a server without a user initiated page load.
E. It makes web applications "advanced".
A. setXHRHeader
B. setRequestHeader
C. sendAdditionalRequestHeader
D. addHeader
A. 301
B. 304
C. 200
D. "cached"
A. the browser window is closed or resized.
B. elements on a page change appearance.
C. users navigate away from a page with unsaved or uncommitted changes.
D. the status of the asynchronous request changes.
E. a user indicates they are ready to continue from a dialog prompt.
A. JSON.parse(returnedData);
B. returnedData.parse("JSON");
C. JSON.stringify(returnedData);
D. returnedData.parse();
A. True
B. False
A. False
B. true
A. Supply a "timeout" argument in the request's .open() method
B. Using setTimeout(), clearTimeout() and .abort()
C. There is no way to manually timeout Ajax requests
A. X-Request-Option: Asynchronous
B. X-Forwarded-For: XMLHttpRequest
C. X-Request-Type: AJAX
D. Proxy-Authorization: Asynchronous
E. X-Requested-With: XMLHttpRequest
A. Yes, but only when transferring image files.
B. Yes, but only in newer browsers by using the responseType property specified in the Level 2 XHR specification.
C. Yes, in newer browsers using the responseType property and in older browsers by overriding the mime type of the response.
D. No, XHR requests only allow text transfer between server and client.
A. A binary protocol, based on JavaScript, for the transmission of application state
B. A data serialization and interchange format using a subset of JavaScript syntax
C. A lightweight, HTML5, browser-based database for storing client-side data.
D. A browser-only data serialization and interchange format based on JavaScript.
E. A JavaScript library for transmitting data between clients and servers.
A. True
B. False
A. Yes, when the P3P header is returned from the server and properly configured.
B. Yes, always.
C. In newer browsers cross-domain requests can be configured but only when servers use special headers to explicitly allow some cross domain requests.
D. No, browser sandboxing rules prevent any asynchronous requests between different document domains.
E. Yes, when the two top level domains share the same SSL certificate.
A. Yes
B. Yes, but only when using newer browsers and HTML5 features.
C. No, not without additional plugins and hacks.
A. False
B. True
A. as an empty string
B. as binary
C. as text/html
D. none of the above
E. as text/xml
A. 301
B. 304
C. 200
D. "redirected"
A. JSON.stringify(dataToSend);
B. dataToSend.stringify();
C. JSON.parse(dataToSend);
D. dataToSend.stringify("serial");
A. The resource is being fetched synchronously so there's no need to wait for a response.
B. The wrong readystate value is being checked for a complete request. The response should only be used when readyState == 5.
C. The timer interval (100ms) is way too fast, a longer polling interval should be chosen to detect for response.
D. This code is polling a timer rather using the onreadystatechange event to check the state of the async request.
A. XDomainRequest
B. CDomainRequest
C. CORSRequest
D. None of the above
E. XMLHttpRequest
A. Confirmed origin response status
B. Cross-origin resource sharing
C. Cross-origin request system
D. Central organized repository service
A. new CorsRequest();
B. new XMLHttpRequest();
C. new CORSRequest();
D. new XDomainRequest();
A. A JavaScript rendering engine
B. Malicious client-side code injection
C. A development framework that assists in writing Ajax-driven applications
D. An extensible stylesheet format designed to be used with Ajax
A. JSONP
B. CORS
C. <script> tags
D. All of these
A. onreadystatechange
B. onprogress
C. onReadyStateChange
D. onProgress
A. Use Ajax to progressively enhance server-side processing, rather than to replace it
B. Add a <meta> tag with the value "dynamic='true'"
C. Use a robots.txt file to transmit the relevant data to the crawler
A. response
B. responseText
C. responseData
D. returnedData
A. Callback functions are used with "asynchronous" requests only
B. req.readyState = callback_function_name;
C. req.trigger(callback_function_name);
D. req.onreadystatechange = callback_function_name;
A. xhr.open("GET", "/resource", false);
B. xhr.open("GET", "/resource", true);
C. xhr.sync("GET", "/resource");
D. xhr.open("GET", "/resource");
E. xhr.request("/resource");
A. 1 (readystate received)
B. true (response received)
C. 4 (readystate complete)
D. "OK" (response good)
E. 200 (response OK)
A. There is no technical limitation; it is a common practice
B. Client-side data is not persisted across browser sessions
C. Client-side data storage is limited to 5MB
D. Client-side code is inherently insecure
A. OPTIONS, GET, PUT
B. PATCH or PLACE
C. PATCH, HEAD, or OPTIONS
D. DRAFT, VALIDATE or SAVE
E. CONNECT, TRACE, or TRACK
A. The server is returning an unencapsulated JSON object which is being executed as JSONP
B. You used the incorrect callback parameter in your request URL
C. The server is rejecting your cross-origin request because you did not supply the correct headers
D. The wrong MIME type has been selected in your Ajax configuration
A. documentXML
B. responseXML
C. XMLDoc
D. XMLDom
E. responseText
A. Lazy-loading of resources
B. Cross-browser compatibility
C. Client-side responsiveness
D. Reduced server processing load
A. The Ajax callback function will run immediately in another thread, allowing the currently-running code to complete as normal
B. The currently-running code will terminate, and the Ajax callback function will be called immediately
C. The Ajax callback function will be queued until the currently-running code completes
A. URL as string, HTTP method as string, CORS flag as boolean
B. URL as string, HTTP method as string, URL parameters as string
C. HTTP method as string, URL as string, async flag as boolean, username as string, password as string
D. HTTP method as string, URL as string