Do you know that? 45% feel secure as a freelancer next

Contact Email: teammmrem@yahoo.com

<< All Upwork (oDesk) and Elance Tests << Elance test answers << IT & Programming category

Test answers for Ajax 2016

(81, CL) Last updated: January 22
Elance • IT & Programming
Questions and answers are regularly updated. Answered and not answered tests questions.

This helps getting job: Hundreds of (cover letter examples , interview questions , profile samples ) • Earn on Upwork (oDesk)
Job assistance: jobs popularityfreelance rates

Popular test answers: HTML, .Net, CSS, English, SEO, Photoshop, iOS, Java, Android, Ruby, Python, JavaScript

See all 6 tests answers updated

Find Upwork (oDesk) and Elance test answers on this website:



Collapse | Expand

81 Answered Test Questions:

1. Which protocol is used to transfer data in an AJAX request?

Answers:

• Hypertext Transfer Protocol, HTTP

• Asynchronous Binary Transfer Protocol, ABTP

• AJAX Object Protocol, AOP

• Advanced Server Protocol, ASP

2. Ajax can be used to open a connection from the server to the browser without the browser making an explicit request.

Answers:

• False

• true

3. For the "same origin policy" to always allow an Ajax request, what attributes must be the same between the requesting context and the server?

Answers:

• IP subnet

• Second-level domain only

• Full domain name

• Domain name, protocol, and port

4. What are the advantages of using JavaScript libraries (like jQuery) to implement Ajax?

Answers:

• There is no advantage

• Better cross-browser compatibility and faster speed of development

• Fewer HTTP requests and smaller loaded resources

5. What does the acronym "blob" stand for when referring to data types?

Answers:

• It is not an acronym

• binned large ordinal byte

• binary large object

• bytes left over from bitstream

6. Which method on the XMLHttpRequest object is used to send custom HTTP headers with a request?

Answers:

• setXHRHeader

• setRequestHeader

• sendAdditionalRequestHeader

• addHeader

7. In standard JavaScript, what makes asynchronous execution of Ajax calls possible?

Answers:

• Deferrals and promises

• Events and callbacks

• Multi-threaded operations

8. Which browser features and/or technologies must be enabled, at a minimum, for AJAX techniques to function properly?

Answers:

• Private browsing must be enabled.

• JavaScript must be enabled.

• A Flash plugin must be installed

• A Java plugin must be installed and enabled.

• Cookies must be enabled.

9. The primary benefit of using AJAX techniques in a web application is:

Answers:

• It makes it easier to create accessible (usable by people of all abilities and disabilities) web pages

• It makes web applications "advanced".

• It makes web applications more easily crawlable by search engines like Google, Yahoo and Bing.

• It makes pages more easily bookmarked, shared and navigated by users using standard browser controls.

• It allows web applications to send asynchronous data requests to a server without a user initiated page load.

10. Is it possible to add custom HTTP header to ajax request?

Answers:

• Yes, it is possible. setRequestHeader() method of XMLHttpRequest object can be used to add a custom HTTP header

• Yes, it is possible. Custom HTTP header can be added while initializing a request with open() method

• Yes, it is possible. Custom HTTP header can be added while initializing a request with init() method

• No, it is not possible

11. How do you manually abort an Ajax request after a certain amount of time?

Answers:

• Using setTimeout(), clearTimeout() and .abort()

• There is no way to manually timeout Ajax requests

• Supply a "timeout" argument in the request's .open() method

12. Which HTML5 feature can improve the experience of a user using the "back" and "forward" buttons when using AJAX techniques?

Answers:

• New browser chrome events: onbackbuttonpressed and onforwardbuttonpressed.

• The history API with pushState, replaceState and history events.

• The version API that allows versioning page interactions.

• The storage API with css3 full page state saving.

13. What is the difference between the XMLHttpRequest object's .status and .statusText attributes?

Answers:

• .status returns a numeric-only code instead of the full HTTP response, which can be found in .statusText

• .status is read-only, while .statusText can be modified

• .statusText is the more widely supported of the two across browsers

• .statusText is not a valid attribute of the XMLHttpRequest object

14. What is the value of the "status" attribute of the completed XMLHttpRequest object if the Ajax request has pulled the response data from the browser cache? Consider only non-IE browsers.

Answers:

• 301

• 200

• "cached"

• 304

15. The onreadystatechange change event is used to invoke behavior when

Answers:

• the browser window is closed or resized.

• elements on a page change appearance.

• users navigate away from a page with unsaved or uncommitted changes.

• the status of the asynchronous request changes.

• a user indicates they are ready to continue from a dialog prompt.

16. If an Ajax request loads JSON-formatted responseText into the variable returnedData, what code will turn the data into a readable JSON object in modern browsers, including IE8 and above?

Answers:

• JSON.parse(returnedData);

• returnedData.parse("JSON");

• JSON.stringify(returnedData);

• returnedData.parse();

17. What is the JavaScript syntax for generating an XML HTTP request object and assigning it to the "xhr" variable? Consider only modern browsers, plus IE7 and above.

Answers:

• var xhr = new XMLHTTPRequest();

• var xhr = new XMLHttpRequest();

• var xhr = navigator.XMLHTTPRequest();

• var xhr = window.XmlHTTPRequest();

18. What is the preferred method for maintaining back/forward button and crawler functionality in Ajax-driven web applications?

Answers:

• < or > in the URL

• history.pushState()

• There is no effective method

• window.location()

19. True or false? A GET request submitted through Ajax can never cause the server to delete data.

Answers:

• True

• False

20. What is the value of the .status attribute of the completed XMLHttpRequest object if the Ajax request needed to follow a server-side redirect before successfully finding the intended resource?

Answers:

• "redirected"

• 304

• 301

• 200

21. How response will be parsed if responseType is set to "document" and the request has been made asynchronously?

Answers:

• none of the above

• as a binary stream

• as a text/html stream

• as an empty string

• as a text/xml stream

22. Most JavaScript libraries that provide AJAX support include this header in AJAX requests by default.

Answers:

• X-Forwarded-For: XMLHttpRequest

• X-Request-Option: Asynchronous

• X-Request-Type: AJAX

• Proxy-Authorization: Asynchronous

• X-Requested-With: XMLHttpRequest

23. What is the purpose of Ajax long-polling?

Answers:

• To check server-side functionality before executing client-side code

• To allow offline functionality in Ajax-driven web applications

• To allow cross-domain data transfer

• To keep a server connection open for two-way communication

24. What does JSON do?

Answers:

• A lightweight, HTML5, browser-based database for storing client-side data.

• A binary protocol, based on JavaScript, for the transmission of application state

• A data serialization and interchange format using a subset of JavaScript syntax

• A JavaScript library for transmitting data between clients and servers.

• A browser-only data serialization and interchange format based on JavaScript.

25. True or false? Ajax can be used to open a connection from the server to the browser without the browser making an explicit request.

Answers:

• False

• True

26. Can an XMLHttpRequest object be used to receive binary data?

Answers:

• Yes, in newer browsers using the responseType property and in older browsers by overriding the mime type of the response.

• Yes, but only when transferring image files.

• Yes, but only in newer browsers by using the responseType property specified in the Level 2 XHR specification.

• No, XHR requests only allow text transfer between server and client.

27. What's wrong with the following code?    function check_for_request_done() {       if (xhr.readyState == 4) {           clearInterval(timer);           do_something_with_result(xhr);       }   }    var xhr = new XMLHttpRequest();   xhr.open("GET", "/resource", true);   xhr.send();    var timer = setInterval(check_for_request_done, 100);

Answers:

• The timer interval (100ms) is way too fast, a longer polling interval should be chosen to detect for response.

• This code is polling a timer rather using the onreadystatechange event to check the state of the async request.

• The wrong readystate value is being checked for a complete request. The response should only be used when readyState == 5.

• The resource is being fetched synchronously so there's no need to wait for a response.

28. If the server is expecting JSON-formatted information in the request, what code will turn the JavaScript object dataToSend into data you can send to the server (consider modern browsers only, including IE8 and above)?

Answers:

• JSON.parse(dataToSend);

• dataToSend.stringify();

• JSON.stringify(dataToSend);

• dataToSend.stringify("serial");

29. What is XSS?

Answers:

• A development framework that assists in writing Ajax-driven applications

• A JavaScript rendering engine

• An extensible stylesheet format designed to be used with Ajax

• Malicious client-side code injection

30. Can you make an XMLHttpRequest asynchronous call to a page on a different top level domain from the current page's top level domain?

Answers:

• No, browser sandboxing rules prevent any asynchronous requests between different document domains.

• In newer browsers cross-domain requests can be configured but only when servers use special headers to explicitly allow some cross domain requests.

• Yes, always.

• Yes, when the P3P header is returned from the server and properly configured.

• Yes, when the two top level domains share the same SSL certificate.

31. Which of the HTTP actions is an Ajax XML HTTP request capable of sending to a server?

Answers:

• GET, POST, and DELETE

• GET, POST, PUT, and DELETE

• GET and POST

• GET, POST and PUT

32. What does CORS stand for?

Answers:

• Central organized repository service

• Cross-origin resource sharing

• Cross-origin request system

• Confirmed origin response status

33. When your Ajax request is complete, what attribute of the XML HTTP request object contains the returned data?

Answers:

• response

• responseData

• responseText

• returnedData

34. What is the syntax for the event listener that monitors whether the XMLHttpRequest object's readyState attribute has changed?

Answers:

• onProgress

• onprogress

• onreadystatechange

• onReadyStateChange

35. How can you load JavaScript from a different file into your web application?

Answers:

• <script> tags

• All of these

• JSONP

• CORS

36. Can you perform file uploads using AJAX requests alone?

Answers:

• No, not without additional plugins and hacks.

• Yes

• Yes, but only when using newer browsers and HTML5 features.

37. What is the name of the object which provides CORS support in Internet Explorer 8 and Internet Explorer 9?

Answers:

• CORSRequest

• CDomainRequest

• XMLHttpRequest

• None of the above

• XDomainRequest

38. Which readystate value indicates the response has been fully received from the asynchronous request?

Answers:

• 200 (response OK)

• true (response received)

• 1 (readystate received)

• "OK" (response good)

• 4 (readystate complete)

39. After a request completes, which property of the XMLHttpRequest object can be used to retrieve a DOM representation of a remote XML document?

Answers:

• documentXML

• XMLDom

• XMLDoc

• responseText

• responseXML

40. What is the CORS-enabled Ajax request object constructor in IE8-9?

Answers:

• new CorsRequest();

• new CORSRequest();

• new XDomainRequest();

• new XMLHttpRequest();

41. Your cross-origin Ajax request is causing your console to throw the error "Resource interpreted as Script but transferred with MIME type application/json. Uncaught SyntaxError: Unexpected token :" What might be happening?

Answers:

• You used the incorrect callback parameter in your request URL

• The server is rejecting your cross-origin request because you did not supply the correct headers

• The wrong MIME type has been selected in your Ajax configuration

• The server is returning an unencapsulated JSON object which is being executed as JSONP

42. Which of these is NOT an advantage of using Ajax over server-side processing?

Answers:

• Client-side responsiveness

• Reduced server processing load

• Cross-browser compatibility

• Lazy-loading of resources

43. What is the proper way to execute a callback function while making a "synchronous" request?

Answers:

• req.trigger(callback_function_name);

• Callback functions are used with "asynchronous" requests only

• req.onreadystatechange = callback_function_name;

• req.readyState = callback_function_name;

44. According to the W3C specification, which HTTP methods should throw a security exception when used with XMLHttpRequest?

Answers:

• OPTIONS, GET, PUT

• PATCH, HEAD, or OPTIONS

• PATCH or PLACE

• DRAFT, VALIDATE or SAVE

• CONNECT, TRACE, or TRACK

45. How would you configure a *synchronous* GET request to "/resource" after instantiating a new XMLHttpRequest object: var xhr = new XMLHttpRequest();?

Answers:

• xhr.sync("GET", "/resource");

• xhr.open("GET", "/resource", true);

• xhr.open("GET", "/resource", false);

• xhr.request("/resource");

• xhr.open("GET", "/resource");

46. What is the technical limitation to implementing user login entirely on the client side using Ajax?

Answers:

• Client-side code is inherently insecure

• Client-side data storage is limited to 5MB

• There is no technical limitation; it is a common practice

• Client-side data is not persisted across browser sessions

47. How does Google recommend you make an Ajax-dependent page accessible to their web crawler?

Answers:

• Use a robots.txt file to transmit the relevant data to the crawler

• Use Ajax to progressively enhance server-side processing, rather than to replace it

• Add a <meta> tag with the value "dynamic='true'"

48. What happens if an Ajax call completes (and calls its callback function) when other JavaScript is currently running?

Answers:

• The Ajax callback function will be queued until the currently-running code completes

• The Ajax callback function will run immediately in another thread, allowing the currently-running code to complete as normal

• The currently-running code will terminate, and the Ajax callback function will be called immediately

49. What HTML attribute would you use to indicate to a screenreader that an element of the page may update using Ajax while out of the user's focus?

Answers:

• aria-active

• aria-live

• aria-polite

• aria-updates

50. What value of the XMLHttpRequest object's readystate attribute indicates that the response data (i.e. not the headers) is currently being sent back from the server?

Answers:

• 3

• The readystate attribute does not provide this information

• 2

• "loading"

51. How do you detect errors in Ajax REQUESTS?

Answers:

• check if .status !== 200

• check if .readyState !== 4

• the onerror event

52. Ajax is frequently expanded as "asynchronous JavaScript and XML," which is misleading. Which of these words is not central to Ajax's functionality?

Answers:

• JavaScript

• asynchronous and XML

• XML

• asynchronous

53. When receiving an image from the server, the responseType attribute of your XMLHttpRequest object must be set to:

Answers:

• "arraybuffer" or "blob"

• "image"

• "blob"

• "arraybuffer"

54. What HTTP response header is expected in reply to a CORS request?

Answers:

• Cross-Origin-Permissions

• Access-Control-Allow-Origin

• Allow-CORS

• Allow-Cross-Origin-Access

55. You've created an XMLHttpRequest object, xhr, and properly called open as well as send on the object. When you check xhr.status and it's 0 and your responseText is null. What's the most likely explanation of what happened?

Answers:

• Your request was canceled either due to a failed connection or a user action.

• The target resource was served from the browser's cache.

• The browser has initiated too many simultaneous XHR requests and this request has been queued.

• The server encountered an unknown error.

• The request has not yet connected to the server.

56. What arguments MUST be supplied to an XMLHttpRequest object's .open() method, and in what order?

Answers:

• HTTP method as string, URL as string

• URL as string, HTTP method as string, CORS flag as boolean

• HTTP method as string, URL as string, async flag as boolean, username as string, password as string

• URL as string, HTTP method as string, URL parameters as string

57. What XMLHttpRequest method is used to override MIME type returned by the server?

Answers:

• init()

• setHeader()

• overrideMimeType()

• setRequestHeader()

58. How does JSONP work?

Answers:

• It sends an HTTP "Access-Control-Allow-Origin" header to the server that asks for permission to make a cross-origin request

• It encodes server responses in a special data type that is ignored by the browser's JavaScript parser

• It makes server response text act like an injected <script> element

59. You're issuing a request to "/resource" using XMLHttpRequest (xhr) where the server returns a 301 or 302 status code, what happens?

Answers:

• Depends on how the XHR object is configured. If xhr.redirects=false, you will need to manually issue new requests otherwise it will automatically follow 301 and 302 redirects, unless the location is on a different domain.

• The readystate will halt at 3 and you must detect the 301 or 302 header and call xhr.continue() for each 301/302 response.

• The readystate will advance to 4 but the responseText and responseXML will be null. You will need to issue a new request to the destination of xhr.getResponseHeader("Location").

• The XHR object will automatically and transparently follow the redirects to the new location for the resource, unless it's on a different domain.

60. What is the value of the response property of XMLHttpRequest object if readyState property equal to 3?

Answers:

• undefined

• 0

• null

• empty string

• partial response body

61. Which property of the popstate event contains a copy of the history entry's state object?

Answers:

• state

• copyState

• currentState

• none of the above

• historyState

62. In non-IE browsers, what attribute should you check your XMLHttpRequest object for in order to see if it supports CORS?

Answers:

• xDomain

• hasCors

• crossDomain

• withCredentials

63. You've created an XMLHttpRequest object, xhr, and properly called open as well as send on the object. When you check xhr.status and it's 0 and your responseText is null. What's the most likely explanation of what happened?

Answers:

• The target resource was served from the browser's cache.

• The request has not yet connected to the server.

• The browser has initiated too many simultaneous XHR requests and this request has been queued.

• Your request was canceled either due to a failed connection or a user action.

• The server encountered an unknown error.

64. What is the value of the .status attribute of the completed XMLHttpRequest object if the Ajax request needed to follow a server-side redirect before successfully finding the intended resource?

Answers:

• 301

• "redirected"

• 304

• 200

65. When using async=true in xmlhttp.open function

Answers:

• connection not established

• response is not constructed

• server crashed

• specify a function to execute when the response is ready in the onreadystatechange event

66. Aalways use POST requests in xmlhttp.open when

Answers:

• update a file or database on the server

• data size is small

• does not require to send user inputs

• security is not an issue

67. The primary benefit of using AJAX techniques in a web application is:

Answers:

• It makes it easier to create accessible (usable by people of all abilities and disabilities) web pages

• It makes web applications more easily crawlable by search engines like Google, Yahoo and Bing.

• It allows web applications to send asynchronous data requests to a server without a user initiated page load.

• It makes web applications "advanced".

• It makes pages more easily bookmarked, shared and navigated by users using standard browser controls.

68. What is the value of the "status" attribute of the completed XMLHttpRequest object if the Ajax request has pulled the response data from the browser cache? Consider only non-IE browsers.

Answers:

• 301

• 304

• 200

• "cached"

69. If an Ajax request loads JSON-formatted responseText into the variable returnedData, what code will turn the data into a readable JSON object in modern browsers, including IE8 and above?

Answers:

• returnedData.parse("JSON");

• JSON.stringify(returnedData);

• returnedData.parse();

• JSON.parse(returnedData);

70. AJAX applications are browser- and platform-dependent!

Answers:

• False

• True

71. How do you manually abort an Ajax request after a certain amount of time?

Answers:

• Supply a "timeout" argument in the request's .open() method

• Using setTimeout(), clearTimeout() and .abort()

• There is no way to manually timeout Ajax requests

72. What's wrong with the following code?    function check_for_request_done() {       if (xhr.readyState == 4) {           clearInterval(timer);           do_something_with_result(xhr);       }   }    var xhr = new XMLHttpRequest();   xhr.open("GET", "/resource", true);   xhr.send();    var timer = setInterval(check_for_request_done, 100);

Answers:

• The timer interval (100ms) is way too fast, a longer polling interval should be chosen to detect for response.

• The resource is being fetched synchronously so there's no need to wait for a response.

• This code is polling a timer rather using the onreadystatechange event to check the state of the async request.

• The wrong readystate value is being checked for a complete request. The response should only be used when readyState == 5.

73. If the server is expecting JSON-formatted information in the request, what code will turn the JavaScript object dataToSend into data you can send to the server (consider modern browsers only, including IE8 and above)?

Answers:

• dataToSend.stringify();

• dataToSend.stringify("serial");

• JSON.parse(dataToSend);

• JSON.stringify(dataToSend);

74. Which readystate value indicates the response has been fully received from the asynchronous request?

Answers:

• "OK" (response good)

• true (response received)

• 1 (readystate received)

• 4 (readystate complete)

• 200 (response OK)

75. How would you configure a *synchronous* GET request to "/resource" after instantiating a new XMLHttpRequest object: var xhr = new XMLHttpRequest();?

Answers:

• xhr.request("/resource");

• xhr.open("GET", "/resource", false);

• xhr.open("GET", "/resource", true);

• xhr.sync("GET", "/resource");

• xhr.open("GET", "/resource");

76. How does Google recommend you make an Ajax-dependent page accessible to their web crawler?

Answers:

• Use a robots.txt file to transmit the relevant data to the crawler

• Use Ajax to progressively enhance server-side processing, rather than to replace it

• Add a <meta> tag with the value "dynamic='true'"

77. What value of the XMLHttpRequest object's readystate attribute indicates that the response data (i.e. not the headers) is currently being sent back from the server?

Answers:

• The readystate attribute does not provide this information

• 2

• "loading"

• 3

78. What is the proper way to execute a callback function while making a "synchronous" request?

Answers:

• req.onreadystatechange = callback_function_name;

• Callback functions are used with "asynchronous" requests only

• req.trigger(callback_function_name);

• req.readyState = callback_function_name;

79. How does JSONP work?

Answers:

• It makes server response text act like an injected <script> element

• It sends an HTTP "Access-Control-Allow-Origin" header to the server that asks for permission to make a cross-origin request

• It encodes server responses in a special data type that is ignored by the browser's JavaScript parser

80. When receiving an image from the server, the responseType attribute of your XMLHttpRequest object must be set to:

Answers:

• "arraybuffer"

• "arraybuffer" or "blob"

• "blob"

• "image"

81. You're issuing a request to "/resource" using XMLHttpRequest (xhr) where the server returns a 301 or 302 status code, what happens?

Answers:

• The readystate will advance to 4 but the responseText and responseXML will be null. You will need to issue a new request to the destination of xhr.getResponseHeader("Location").

• Depends on how the XHR object is configured. If xhr.redirects=false, you will need to manually issue new requests otherwise it will automatically follow 301 and 302 redirects, unless the location is on a different domain.

• The XHR object will automatically and transparently follow the redirects to the new location for the resource, unless it's on a different domain.

• The readystate will halt at 3 and you must detect the 301 or 302 header and call xhr.continue() for each 301/302 response.