Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

See if you can modify the code of Listings 17.1 and 17.3 to present a message to the user while waiting for an Ajax request

See if you can modify the code of Listings 17.1 and 17.3 to present a message to the user while waiting for an Ajax request to complete.

17.1

function getXMLHttpRequest()

{

try {

try {

return new ActiveXObject("Microsoft.XMLHTTP");

}

catch(e) {

return new ActiveXObject("Msxml2.XMLHTTP");

}

}

catch(e) {

return new XMLHttpRequest();

}

}

function doAjax( url, query, callback, reqtype, getxml)

{

var myreq = getXMLHttpRequest();

myreq.onreadystatechange = function()

{

if( myreq.readyState == 4)

{

if( myreq.status == 200)

{

var item = myreq.responseText;

if( getxml == 1) item = myreq.responseXML;

eval(callback + '( item)');

}

}

}

if(reqtype.toUpperCase() == "POST")

{

requestPOST( url, query, myreq);

} else {

requestGET(url, query, myreq);

}

}

function requestGET(url, query, req)

{

var myRandom = parseInt(Math.random()* 99999999);

if( query == '')

{ var callUrl = url + '?rand=' + myRandom;

} else { var callUrl = url + '?' + query + '&rand=' + myRandom;

}

req.open("GET", callUrl, true);

req.send( null);

}

function requestPOST(url, query, req)

{

req.open("POST", url, true);

req.setRequestHeader(' Content-Type', 'application/ x-www-form- urlencoded');

req.send(query);

17.3

Keywords Grabber

http://

Keywords Received:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Discuss the characteristics of emerging adulthood.

Answered: 1 week ago

Question

Are all governmental services paid for by general taxes

Answered: 1 week ago

Question

2. Are you varying your pitch (to avoid being monotonous)?

Answered: 1 week ago

Question

3. Are you varying your speaking rate and volume?

Answered: 1 week ago