// The code from here is very much standard for all ajax code

var data = "";

// This code get the data from the server
function ajaxFunction() // This code requests the object from the server and defines that the object shall go into a variable called object and also checking the type of browser used
{

	var xmlHttp; // This variable is created to hold the object coming from the server
	
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
			  // Internet Explorer
			  try
				{
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
				}
			  catch (e)
				{
						try
						  {
						  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
						  }
						catch (e)
						  {
						  alert("Your browser does not support AJAX!");
						  return false;
						  }
				}
	  }

	// This code makes is possible to receive the data by using information from the object we create above. Defines where the object content is going to end up
	
	xmlHttp.onreadystatechange=function() // The onreadystatechange property stores the function that will process the response from a server
	{
		if(xmlHttp.readyState==4) // Stage 4 means that data transfer is going to be OK and we can define what text to go into the object
		  {
		  data = eval(xmlHttp.responseText); // Gets the data from the datasource.php file and puts it into an array called data
		  }
	}
	
	
	// This code send a request to the server to get the object. We do first have to open the connection with the server and then actually send the request
	
	var url="datasource.php"; // Defines the url (filename) to the server where you want to get data from on the server. Goes into the xmlHttp.open below
	xmlHttp.open("GET",url,true); // The open() method takes three arguments. The first argument defines which method to use when sending the request (GET or POST). The second argument specifies the URL of the server-side script (the file where we want to extract data from). The third argument specifies that the request should be handled asynchronously
	xmlHttp.send(null); // The send() method sends the request off to the server
	
}

