AJAX Test Upwork

How can you stop jQuery AJAX response from being cached?

Set cache:false in jQuery.ajax() call
Set cache:true in jQuery.ajax() call
Set caching:false in jQuery.ajax() call
None of the above

How can you send cookies in CORS Ajax call ?

You must set the withCookie flag on the XMLHttpRequest transport.
xhr.withCookie = true;
You must set the withCredentials flag on the XMLHttpRequest transport.
xhr.withCredentials = true;
You must set the cookies data on the XMLHttpRequest transport.
xhr.cookies = {cookie here};
None of the above

Which of the following is true about the jQuery.post() method?

Load data from the server using an HTTP POST request
Load data from the server using an HTTP GET request
Both of the above
None of the above

What is the correct way to implement POST request using AJAX?

xhttp.browse(“POST”, “demo_post.asp”, true);xhttp.send();
xhttp.open(“POST”, “demo_post.asp”, true);xhttp.send();
xhttp.open(“POST”, “demo_post.asp”, true);xhttp.post();
Both 1 and 2.

Which of the answer is correct to send following data with request?
var requestData = "username=" +
      escape(document.getElementById("username").value) + "&password=" +
      escape(document.getElementById("password1").value) + "&firstname=" +
      escape(document.getElementById("firstname").value) + "&lastname=" +
      escape(document.getElementById("lastname").value) + "&email=" +
      escape(document.getElementById("favorite").value);

abcRequest.open("POST", url, true);
abcRequest.send(requestData);

abcRequest.open("GET", url, requestData, true);
abcRequest.send(null);

abcRequest.open("GET", url, true);
abcRequest.send(requestData);

abcRequest.open("POST", url, true);
abcRequest.send('requestData');

Choose the best answer to describe ‘Deferred objects’

A future value object
A response to a JSONP request
A response to  a XMLHTTPRequest
jQuery's custom implementation of promises

Which of the following property of XMLHttpRequest object holds its status?

Status
State
readyState
readyStatus

Which of the following JavaScript DOM traversal method works with an XML Document object?

getElementsByTagName
getElementById
querySelectorAll
getElementSelect

Which of the following method is NOT supported by the XMLHttpRequest object?

open
quit
send
None of the above

What is wrong in the following function ?
function loadDoc() {
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 3 && this.status == 200) {
            console.log(this.responseText);
        }
    };
    xhttp.open("GET", "cd_catalog.xml", true);
    xhttp.send();
}

In line 4, the comparison of this.status should be with 404
In line 4, the comparison of this.readyState should be with 4
None of the above

To check if DOM element 'currentDiv' don't have any child nodes, we can use one of the following condition?

currentDiv.childNodes.length == 0
currentDiv.childNodesPresent == 0
currentDiv.isChildNodes == 0

For the code fragment below
function foo() {
    var httpRequest = new XMLHttpRequest();
    httpRequest.open('GET', "/echo/json");
    httpRequest.send();
    return httpRequest.responseText;
}
var result = foo();
What will be the value of 'result'?

Null
Undefined
A Promise
Char arrayy

The responseText property returns the response as a Number?

True
False

Which of the following is correct for the term 'Progressive enhancement'? (choose all that apply)
Note: There may be more than one right answer.

A design that will not work on low-capability browsers
A design that allows operation at a reduced level of performance after browser failures
Progressive enhancement allows everyone to access the basic content and functionality of a web page, using any browser or Internet connection, while also providing an enhanced version of the page to those with more advanced browser software or greater bandwidth.
The reverse of 'Graceful Degradation'

Complete the following sentence.
Using AJAX we can make our web page ___.

have beautiful graphics
interactive and faster
process request smoothly in server
None of the above

Which of the following is true for asynchronous requests and response? (choose all that apply)
Note: There may be more than one right answer.

Never count on the ORDER or SEQUENCE of requests and responses in asynchronous applications.
If you’re making TWO separate requests, use TWO separate request objects.
Asynchronous request and response received are in sequence.
Same Request Object can be used for two separate.  ???

.................... stores a function (or the name of a function) to be called automatically each time the readyState property changes.

onreadystatechange
readyState
status
All of the above

Which of the following is true to convert AJAX JSON response into object? Check all that apply.
Note: There may be more than one right answer.

eval(' + request.responseText + ');
eval('{' + request.responseText + '}');
eval(request.responseText);
eval('(' + request.responseText + ')');

Which of the following is the correct way to disable the register button while the request is processing?

document("register").disabled = true;
document.getElementById("register").active = true;
document.getElementById("register") = true;
document.getElementById("register").disabled = true;

Your AJAX requests are giving you cross site scripting issues, choose the best method below to get around this.

Run a proxy script on your own server that fetches the content from the external site and pipes it back to the browser
Use an iframe for the AJAX requests
Use JSONP for both GET and POST requests
Explicitly use the XmlHttpRequest object

Which of the following is true about onreadystatechange?

onreadystatechange is a function to be called when XMLHttpRequest is ready
onreadystatechange is a function to be called automatically each time the readyState property changes
onreadystatechange is a property that contains state of XMLHttpRequest
None of the above

This __ event tells the browser to call the checkUsername() function when the user leaves the username field on the form.

onleave
onblur
onexit
onnext

Which of the following objects can be accessed from JavaScript code?
Note: There may be more than one right answer.

document
history
window
XMLHttpRequest

For the following code fragment:
object.property();
Choose the option that is correct.

When you get the property from the object and call it in one go, the window will be the context for the method.
If you call the property() method  in separate steps, the context is the object.
When you get the property from the object and call it in one go,  the object will be the context for the method.
When you get the property from the object, the context is the global scope.

How do you know that an AJAX request has completed?

XHR.readyState is 1 and the XHR.status is 200
XHR.readyState is 2 and the XHR.status is 200
XHR.readyState is 4 and the XHR.status is 400
XHR.readyState is 4 and the XHR.status is 200

Which of the following statements best describes the below code?
(function worker() {
    $.ajax({
        url: 'ajax/test.html',
        success: function(data) {
            $('.result').html(data);
        },
        complete: function() {
            setTimeout(worker, 5000);
        }
    });
})();

Syntax error
Periodically performs an AJAX request
Performs an AJAX request once
None of the above

Which of the following request object property tells us when the server has finished processing?

status
responsetext
statustext
readystate

Which of the following statements are true for AJAX graceful degradation?
Note: There may be more than one right answer.

Start out by designing a JavaScript-free site.
Use <a> elements and Submit buttons.
Write server-side programs that don’t assume Ajaxian requests.
Test your pages on non-javascript browser

For the code fragment below
$.ajax({
type: 'POST',
url: 'submit1.php',
data: $("#regist").serialize(),
dataType: 'json',
success: function() { // code here} });
Choose the statement that best describes the role of the success ‘key’

Defines an AJAX callback
Defines an AJAX asynchronous callback
Defines an AJAX callback for a response with status code 200
Defines an AJAX callback with content type application/json

Which one of these technologies is NOT used in AJAX?

CSS
DOM
JavaScript
Flash

Why would a public api return a non valid json like this?
for(;;); {"key1":val1,"key2": "val2"}

These strings are commonly referred to as an "unparseable cruft" and are security measures.
It would be a bad HTML not json.
To prevent an XHR attack.
To prevent developers from using eval directly.

Which of the following will change the class of XHTML element having ID of 'username'?

document.getElementById("username").class = "approved";
document.getElementById("username").className = "approved";
document.getElementsByClassName("username").className = "approved";
document.getElementsByTagName("username").className = "approved";

Which of the following is not a 'document' object method?

document.createElement()    
document.removeChild()
document.replaceChild(element)
document.replace(element)

Which object.method is responsible for writing text to current web page?

window.write
document.write
XMLHttpRequest.write
history.write

What does the following code do?
var xhttp, xmlDoc, txt, x, i;
xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
        xmlDoc = this.responseXML;
        txt = "";
        x = xmlDoc.getElementsByTagName("QUESTION");
        for (i = 0; i < x.length; i++) {
            txt = txt + x[i].childNodes[0].nodeValue + "<br>";
        }
        document.getElementById("demo").innerHTML = txt;
    }
};
xhttp.open("GET", "questions.xml", true);
xhttp.send();

responseXML gets response as HTMLDocument
responseXML gets response as XMLFile
responseXML gets response as XMLDocument
None of the above

Which of the following is the correct way to assign events to HTML elements using JavaScript?

document.onclick = functionName;
window.onload = functionName;
Events can't be assigned using javascript
document.getElementById("Btn").onclick = functionName;

To prevent DOM based XSS attacks when JSON is returned in response, which of the following is not correct?

Don't use the eval() function to parse JSON.
Use JSON.parse(). For older browsers use json2.js
Use the eval() function to parse JSON
None of the above

What does the getAllResponseHeaders() function do ?
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
        console.log(this.getAllResponseHeaders());
    }
};
xhttp.open("GET", "ajax_info.txt", true);
xhttp.send();

Get all request headers of Ajax call
Get all body content of Ajax call
Get all response headers of Ajax call
None of the above

How does Crockford's json2.js libary support Graceful Degradation?

By using JSON.stringify
By using JSON.parse
Crockford's JSON library will only define JSON.stringify and JSON.parse if they're not already defined, leaving any browser native implementation intact.
By defining JSON.stringify and JSON.parse

Which of the following is not supported in AJAX?

CSS
Flash
JS
None of the above

The browser will put 'text' that the server returns in which Request Object property?

response
responseText
statustext
text

Can we make an HTTP POST Ajax call?

Yes, set method param of open() function to POST
No
Yes, but POST can not run in all browsers

The jQuery AJAX methods .get(), .post(), and .ajax() all require which parameter to be supplied? 1

method
url
data
headers

The jQuery AJAX methods .get(), .post(), and .ajax() all require which parameter to be supplied? 2

url
data
method
header

Which of the following statements is true about the following code?
$.ajax({
    method: "GET",
    url: "test.js",
    dataType: "script"
});

Invalid AJAX request
Load JavaScript file but does not execute it
Load and execute the JavaScript file
None of the above

What will be XMLHttpRequest object 'status' when page was not found?

200
404
'403'
300

To get a list of all <p> elements with class="intro", which of the following can be used?

document.getElementById("p.intro");
getElementsByClassName("p.intro")
document.querySelectorAll("p.intro");
document.getElementsByTagName("p.intro")

What is the difference between XMLHttpRequest and ActiveXObject?
variable = new XMLHttpRequest();
variable = new ActiveXObject("Microsoft.XMLHTTP");

ActiveXObject is for modern browser, XMLHttpRequest is for old browser such as IE5, IE6
ActiveXObject & XMLHttpRequest have no difference, both can run on all browsers
ActiveXObject is for old browser such as IE5, IE6, XMLHttpRequest is for modern browser
None of the above

For the code fragment
function x(a,b,e,d,c){
c=new XMLHttpRequest;
c.open(e||'get',a);
c.onload=b;
c.onerror=error;
c.send(d||null) }
Choose the option that best describes the parameter d

Form data
A callback
A url
Data

How can you make a cross-domain Ajax call?

By using JSONP
By using CORS
Byusing both JSONP and CORS
None of the above

If an AJAX request made using jQuery fails,

the browser will automatically report the problem with an alert message.
an error message will be displayed in the browser window content area.
the programmer should arrange for it to be reported using the jQuery .fail() method.
there is no way to notify the user.

Choose the best statement for the expression.
JSON.stringify(jsObj);

Will fail if the browser lacks native JSON serialization
Will fail without Crockford's json2.js libary
Will fail without jQuery libary
Will fail if called before 'window.onLoad'

Which of the following benefits can AJAX provide to Web Applications?
Note: There may be more than one right answer.

The browser can request multiple things from the server at the same time.
Browser requests return a lot faster.
Colors are rendered more faithfully.
Only the parts of the page that actually change are updated

If something goes wrong at the server,  __ property of request object tell us about it.

error
status
response
log

Which of the following methods can be used to delete node from DOM tree?

deleteNode()
removeNode()
deleteObject()
remove()

How many statuses of the XMLHttpRequest are there?

Four : from 0 to 3
Three : from 0 to 2
Five : from 0 to 4
Two : from 0 to 1

Which of the following functions is used to return specific header information from the server response?

getResponseHeader(
getHeader()
header()
getRequestHeader()

Which of the following request object methods can be assigned a callback function which will be called every time the server updates the browser on the request its processing?

request.onstatechange
request.onreadystatechange
request.statechange
request.onstatuschange

Can the XMLHttpRequest object be disabled via browser settings?

Yes
No
Can be changed from server
Depends

How can you use Basic Auth with jQuery and AJAX?

Use username and password attribute with the $.ajax call
Use the beforeSend callback to add a HTTP header with the authentication information
Both of the above
None of the above

For the following code fragment:
function Foo() {
    this.data = 42,
    document.body.onclick = this.method;
}
Foo.prototype.method = function() {
    console.log(this.data);
};
Choose the option that shows the output to the console log.

undefined
42
null
error

For the following code fragment
function Foo() {
    this.data = 42,
    document.body.onclick = this.method.bind(this);
  }
Foo.prototype.method = function() {
    console.log(this.data);
};
choose the option that shows the output to the console log

undefined
Evalerror
Referenceerror
42

In Javascript, which of the following events can we set? (choose all that apply)
Note: There may be more than one right answer.

onabort
ondblclick
onresize
onsave

Which of the following methods are available for XMLHttpRequest?
Note: There may be more than one right answer.

getResponseHeader(headerName)
getURL()
open(method, URL)
open(method, URL, async, username, password)

Which of the following is not an XMLHttpRequest Method?

setRequestHeader
setResponseHeader
open
send

For the code fragment below,
function ajax(a,b,c) {   
c=new XMLHttpRequest;
c.open('GET',a);
c.onload=b;
c.send() }
Choose the option that best describes the parameter c

A callback
A promise
A variable definition
A response

Which of the following are HTTP request headers?
Note: There may be more than one right answer.

Accept-Charset
Authorization
To
Referrer

What is the correct way to implement GET request using AJAX?

xhttp.open(“GET”, “demo_get.asp”, true); xhttp.send();
xhttp.open(“GET”, “demo_get.asp”, true); xhttp.post();
xhttp.open(“POST”, “demo_get.asp”, true); xhttp.send();
None of the above

Which object shares a powerful set of methods that can be used to expedite communications between the client and server?

HttpRequest()
AJAXHttpRequest()
XMLHttpRequest()
JSONHttpRequest()

For the following code fragment
foo(function(r) { // code  });
Choose the correct description of the ‘function(r)’

An Asynchronus function
A closure
A callback
A nested function

What does the status == 404 mean?

the Ajax call to the page was not found
the Ajax call to the page is success
the Ajax call to the page has internal error
the Ajax call to the page is redirected

Which of the following will not execute request asynchronously, provided usernameRequest object already exists?

usernameRequest.open("GET", "abc.php", true);
usernameRequest.send(null);

usernameRequest.open("GET", "abc.php", false);
usernameRequest.send(null);

usernameRequest.open("POST", "abc.php", true);
usernameRequest.send(null);

usernameRequest.open("GET", "abc.php", true);
usernameRequest.send("fname=John&lname=Alice");

Which of the following are HTTP response headers?
Note: There may be more than one right answer.

Age
Public
Retry
Retry-After

__ function returns a JavaScript object that represents an XHTML element.

getElementsByClass()
innerHTML()
createElement()
getElementById()

Which of the following methods can be used to assign multiple event handlers?

addEventHandler()
addEvent()
createEvent()
addEventListener()

Which of the following callback hooks is not provided by jQuery AJAX?

beforeSend
error
dataFilter
success
finish
complete

AJAX has become very commonly used because

it allows page content to be updated without requiring a full page reload.
it avoids the need for JavaScript.
XML is a close relative of HTML.
it allows pages to be interactive without further communication with the server.

Which of the following is NOT a valid method in the key/value pair to configure ajax request in jquery.ajax()?

complete
pass
success
error

Can ActiveXObject work on browsers like Chrome and Firefox?

Yes. ActiveX can work on all browsers
No, ActiveX is only supported by IE - the other browsers use a plugin architecture called NPAPI
ActiveX can work on Chrome but not on Firefox
ActiveX can work on Firefox but not on Chrome

Which of the following may be a disadvantage of using AJAX?

Security
Search Engine Indexing
Accessibility Issues
All of the above

How can you perform a synchronous AJAX request in jQuery?

In AJAX request, set async: false
In AJAX request, set async: true
Ajax request cannot be synchronous
In AJAX request, set asynchronous: false

Which of the following is true about the callback function? Check all that applies.
Note: There may be more than one right answer.

A callback function is a function that is executed when something else finishes.
In Ajax, it’s the function that’s called when the server responds to a request object. The browser “calls back” that function at a certain time.
A callback function is a function that is executed immediately.
A callback function is a function that is executed when when request is submitted to browser.

Fill the correct blanks in following code:
Function processXhrChange() {
    // Check readyState to make sure the XMLHttpRequest has been fully loaded
    if (Xhr.readyState == ______ ) {
        // Check status code from server for "OK"
         if ( Xhr.status == ______ ) {
             // Process incoming data
             // Update our hit counter
             Hit = hit + 1;
}
else {
        // Request had a status code other than 200
        Alert ("There was a problem communicating with the server\n");
    }
}

2
200

4
200

3
300

0
200

Which option should be set in jQuery AJAX call to send a DOMDocument?

set processData to true
set processData to false
set data to true
set data to false

In an AJAX request function callback, you have the following code:
$('#childdiv').html(data);
 choose the most probable reason why a previous delegated 'click' event  no longer functions

If you do use event delegation, you must bind to a non-changing parent element.
Ajax callback is not implemented
You need to  trigger UI actions in between ajax calls
You need to call document.onload to refresh the dom

Which of the following readyState Object Status is not correct?

0 = initialized
1 = loading
2 = loaded
3 = interactive

Which of the following methods is used for cross domain AJAX calls?

CORS
JSONP
Both of the above
None of the above

AJAX is used to create a very _____ web interface.

dynamic
fast
graphically beautiful
static

Which of the following can be used to display 'inProcess.png' image while processing request?

document.getElementById("status").image = url("inProcess.png");
document.getElementById("status").innerHTML = url("inProcess.png");
document.getElementById("status").src = "inProcess.png";
document.getElementById("status").attribute=  "inProcess.png";

Which of the following javascript functions can be used to convert JSON string into object?

JSON.convert()
JSON.parse()
JSON.object()
JSON.string()

Which of the following is true about asynchronous request? (choose all that apply)
Note: There may be more than one right answer.

Allow the user to keep working while request is taking place
User has to wait while request is taking place
While loading page, browser always makes asynchronous request
Asynchronous request can only be executed using javascript

Which of the following parameters to request.open() are correct?
Note: There may be more than one right answer.

request.open("GET", url, true);
request.open("POST", url, true);
request.open("DELETE", url, true);
request.open("GET", url, "sync");

Which of the following is a feature of AJAX?

Live data binding
Client-side template rendering
Declarative instantiation of client components
Observer pattern on JavaScript objects and arrays
All of the above

Which of the following is not a valid data type that AJAX expects to get from server?

xml
html
sql
json

Which of the following XMLHttpRequest properties are correct?
Note: There may be more than one right answer.

Onreadystate
readyState
responseText
statusText

Which of the following are XMLHttpRequest object methods?
Note: There may be more than one right answer.

send()
open()
url()
success()

What does the readyState property in onreadystatechange event equal to 1 mean?

processing request
server connection established
request received
request finished and response is ready

Which of the following are valid for addEventListener() method?

Attaches an event handler to the specified element.
Attaches an event handler to an element without overwriting existing event handlers.
Can add many event handlers of the same type to one element, i.e two "click" events.
Makes it easier to control how the event reacts to bubbling.
All of the above

After all referenced files are loaded and parsed, the browser triggers the _____ event.

document.init
windows.init
window.onload
document.onload

Which of the following is not a callback hook provided by $.ajax()?

beforeSend
dataFilter
failure
complete

Which of the following numbers, in callback function of request object, can be tested against request.readyState to make sure that the server has finished processing the request?

1
2
3
4

Which of the following is true about jQuery.get() method?

Load data from the server using an HTTP GET request
Load data from the server using an HTTP POST request
Both of the above
None of the above

Which of the following XMLHttpRequest Object methods returns all the header information?

getHeaders()
getResponseHeaders()
getAllResponseHeaders()
getAllHeaders()

Which of the following jQuery AJAX functions is used to set default values for future AJAX requests?

jQuery.ajaxSetup()
jQuery.ajaxSend()
jQuery.ajaxDefault()
None of the above

Which of the following JavaScript object performs asynchronous interaction with the server?

XMLHttpRequest
HttpRequest
AJAXHttpRequest
XMLRequest

Which of the following values of readyState means that an AJAX request has been completed?

1
2
3
4

Which of the following are General HTTP headers?
Note: There may be more than one right answer.

Connection
Date
Mime-Version
Trailer

The responseText or responseXML is a property of the XMLHttpRequest ____.

object
id
url
method

AJAX Test Upwork 2019