0

I am confused right now, and there will be test about ajax tommorrow..

And i bumped into this getXMLHTTP() function in one of the code that my professor gave me and i not sure what it does exactly.I mean because i also see in the other code, that people are using getXMLHttpRequest() in their ajax code and this make me more confused.

I have tried finding it on the net but theres no one yet given explanation on this. So i hope someone could give me explanation on this.

By the way, below this is the example of code that using this function :

function getInfo(strURL)
{		
	var req = getXMLHTTP();		
	if (req) 
	{
		req.onreadystatechange = function()
		{
			if (req.readyState == 4) 
			{			
				if (req.status == 200)
				{						
					document.getElementById("lect").innerHTML=req.responseText;						
				} 
				else 
				{
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		 }			
		 req.open("GET", strURL , true);
		 req.send(null);
	}			
}

thank you in advance :)

Edited by samsons17: n/a

2
Contributors
2
Replies
5
Views
6 Years
Discussion Span
Last Post by tgreer
0

oouh2...i am so sorry...
actually getXMLHTTP() is the function that being made...
haha..sory for this...
anyway thanks :)

0

The XMLHTTP object is the core of AJAX functionality. It's essentially a way to call a web page roundtrip from within code. Depending on your browser, the exact syntax to call the XMLHTTP object differs. It might be as simple as:

new XMLHttpRequest

Or you might need to use an ActiveX object:

new ActiveXObject("Microsoft.XMLHTTP")

What's common in script is to declare a function that has try/catch blocks for the various ways of instantiating the XMLHTTP object, and most sample code out there defines that function as getXMLHTTP().

So in your code snippet, we see a function named getXMLHTTP() called, but we don't see that function actually defined.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.