AJAX Background Send Without Caring About Response


function ajax_send_slider_value (slider_value_to_send)
{
	AjaxRequest1Parameters = "action=do_something";			//<<<<<SET PARAMETER TO POST (id1=val1&id2=val2 for multiple parameters)
	AjaxRequest1 = new ajaxRequest();
	AjaxRequest1.open("POST", "ajax.php", true);										//<<<<<SET THE FILE TO POST THE REQUEST TO
	AjaxRequest1.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
	AjaxRequest1.setRequestHeader("Content-length", AjaxRequest1Parameters.length);
	AjaxRequest1.setRequestHeader("Connection", "close");

	//SEND THE AJAX REQUEST
	AjaxRequest1.send(AjaxRequest1Parameters);			//Use (null) if there are no parameters to send
}




//************************************************
//************************************************
//********** CREATE AJAX REQUEST OBJECT **********
//************************************************
//************************************************
function ajaxRequest()
{
	//Cross browser - deal with IE varients
	try
	{
		//Non IE Browser
		var request = new XMLHttpRequest();
	}
	catch(e1)
	{
		try
		{
			//IE6?
			request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e2)
		{
			try
			{
				//IE5?
				request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e3)
			{
				//There is no Ajax support in this browser
				request = false;
			}
		}
	}
	return request;
}

 

 

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *