GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Web  >  AJAX
Go To First  |  Previous Question  |  Next Question 
 AJAX  |  Question 44 of 53    Print  
What are the steps for handling concurrent requests in AJAX?

  
Total Answers and Comments: 4 Last Update: August 18, 2008     Asked by: RajivPrasad 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: innovativesparkle
 
AJAX - Asynchronous Java Script AND XML.
Using AJAX your Java script can directly communicate with server.

AJAX use XMLHttpRequest Object to communicate with Server..

Now It Works..

XMLHttpRequest Object have three Different Properties.

1) OnReadyStateChangePropert -  After Request to Server You need a Function to store the Response from Server.

xmlHttp.onreadystatechange = function (){

}

2) ReadyState =  Using This Propert you can Check the Response State.

ReadyState  = 0  It Means Request Initialized
ReadyState  = 1  It Means Request set up
ReadyState  = 2  It Means Request sent
ReadyState  = 3  It Means Request Progress
ReadyState  = 4  It Means Request Complete

3) ResponseText =  Data Sent By Server will get By Response Text Property.

Steps...
1) First Check The xmlHttp Request Object Which Supports your Browser

Internet explorer -- ActiveXObject
FireFox                 -- XmlHttpRequest Object

2) Then Use These Property

xmlHttp.onReadyStateChange = function () {

          if (xmlHttp.ReadyState == 4)
          {
                document.getelementByid.innerHtml('center') = xmlHttp.ResponseText;
          }

}

3)xmlHttp.open("GET","Name of Page , you are requesting",true);
4)xmlHttp.send(null);



Above answer was rated as good by the following members:
sheelaForum
July 09, 2007 01:01:46   #1  
Arvind        

RE: What are the steps for handling concurrent request...
I believe it can be done by creating the XMLHTTPRequest object from within an inner function instead of creating a seperate function for making a new XmlHttprequest object withing the same page...

Hope this helps!!

Regards

 
Is this answer useful? Yes | No
March 17, 2008 19:08:03   #2  
jollykid Member Since: March 2008   Contribution: 1    

RE: What are the steps for handling concurrent requests in AJAX?
In order to handle the request concurrently its always better to achive through writing the separate function. For e.g.

xmlHTTPObj.Onreadystatechange function1();

The above line of code will help us to do asynchronous processing. So function1() will be called when the XMLHTTP request object goes to on ready state change.

Dont forget to set the parameter "TRUE" in the Open method of xmlHTTPObj. The followign e.g. shows this.

xmlHTTPObj.open("GET" "http://"+location.host + "XMLHTTPExample1/Webform1.aspx" true)

"true" reperesents the processing carried after the send() method without waiting for a response. "false" means that processing waits for the response before continuing.

Thanks
Venkatesh Kumar

 
Is this answer useful? Yes | No
May 04, 2008 14:37:34   #3  
innovativesparkle Member Since: February 2008   Contribution: 1    

RE: What are the steps for handling concurrent requests in AJAX?
AJAX - Asynchronous Java Script AND XML.
Using AJAX your Java script can directly communicate with server.

AJAX use XMLHttpRequest Object to communicate with Server..

Now It Works..

XMLHttpRequest Object have three Different Properties.

1) OnReadyStateChangePropert - After Request to Server You need a Function to store the Response from Server.

xmlHttp.onreadystatechange function (){

}

2) ReadyState Using This Propert you can Check the Response State.

ReadyState 0 It Means Request Initialized
ReadyState 1 It Means Request set up
ReadyState 2 It Means Request sent
ReadyState 3 It Means Request Progress
ReadyState 4 It Means Request Complete

3) ResponseText Data Sent By Server will get By Response Text Property.

Steps...
1) First Check The xmlHttp Request Object Which Supports your Browser

Internet explorer -- ActiveXObject
FireFox -- XmlHttpRequest Object

2) Then Use These Property

xmlHttp.onReadyStateChange function () {

if (xmlHttp.ReadyState 4)
{
document.getelementByid.innerHtml('center') xmlHttp.ResponseText;
}

}

3)xmlHttp.open("GET" "Name of Page you are requesting" true);
4)xmlHttp.send(null);


 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
August 16, 2008 02:24:45   #4  
r4zeal Member Since: August 2008   Contribution: 1    

RE: What are the steps for handling concurrent requests in AJAX?
3) xmlHttp.open( GET Name of Page you are requesting true);

Can anyone explain how can I use POST method for sending data to Servlet? I want to send an object which contains all the data directly to servlet instead of GET

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape