﻿//Make a Request
function ContentRequest(requestUrl) 
{
	FillTarget("Laden...");
	CreateXmlHttp();
	if(XmlHttp) // (present if CreateXmlHttp() succeeded)
	{
		//Setting the event handler for the response
		XmlHttp.onreadystatechange = HandleResponse;
		
		//Initializes the request object with GET (METHOD of posting), 
		//Request URL and sets the request as asynchronous.
		XmlHttp.open("GET", requestUrl,  true);
		
		//Sends the request to server
		XmlHttp.send(null);		
	}	
}


//Called when response comes back from server
function HandleResponse()
{
	// To make sure receiving response data from server is completed
	if(XmlHttp.readyState == 4)
	{
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp.status == 200)
		{	
		    flag = true	
		    FillTarget(XmlHttp.responseText);
		}
		else
		{
		    window.close();
		}
	}
}

function FillTarget(content) {
		var target = document.getElementById("ajaxWorkDetails");
		if(target) {
			target.innerHTML = content;
		} else {
			// target not found, ignore.
		}
}

