| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 
 | function getXMLHttpRequest() 
{
	var xhr = null; 
	if (window.XMLHttpRequest || window.ActiveXObject)
	{
		if (window.ActiveXObject)
		{
			try
			{
				xhr = new ActiveXObject("Msxml2.XMLHTTP");
			} 
			catch(e)
			{
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
		} 
		else
		{
			xhr = new XMLHttpRequest(); 
		}
	}
	else
	{
		alert("Votre navigateur ne supporte pas l'objet XMLHTTPRequest...");
		return null;
	}
	return xhr;
}
var xhr = getXMLHttpRequest();
 
 
function refreshpage() 
{
	var xhr = getXMLHttpRequest();
	xhr.onreadystatechange = function() {
		if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
			document.getElementById('test_ajax').innerHTML = xhr.responseText;
		}
	};
 
	xhr.open("GET", "insert_line.php", true);
	xhr.send(null);
}
 
 
function submitpage()
{
	var xhr = getXMLHttpRequest();
	var contact = encodeURIComponent(document.getElementById('contact').value);
	var description = encodeURIComponent(document.getElementById('description').value);
	var travail = encodeURIComponent(document.getElementById('travail').value);
	xhr.onreadystatechange = function() {
		if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
			document.getElementById('test_ajax').innerHTML = xhr.responseText;
		}
	};
 
	xhr.open("POST", "insert_line.php", true);
	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xhr.send("contact="+contact+"&description="+description+"&travail="+travail);
 
}
 
function supprime(ident){
	var xhr = getXMLHttpRequest();
	xhr.onreadystatechange = function() {
		if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
			if(xhr.responseText=="OK"){
				var a = document.getElementById="ligne"+id;
				a.parentNode.removeChild(a);
				document.getElementById('test_ajax').innerHTML = xhr.responseText;
			}
		}
	};
 	xhr.open("POST", "delete_line.php", true); 
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr.send("ident="+ident);
}
 
function updatepage(ident)
{
	var xhr = getXMLHttpRequest();
	var contact = encodeURIComponent(document.getElementById('contact').value);
	var description = encodeURIComponent(document.getElementById('description').value);
	var travail = encodeURIComponent(document.getElementById('travail').value);
	xhr.onreadystatechange = function() {
		if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
			document.getElementById('test_ajax').innerHTML = xhr.responseText;
		}
	};
 
	xhr.open("POST", "test_ajax.php", true);
	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xhr.send("ident="+ident);
}
 
function update()
{
	var xhr = getXMLHttpRequest();
	var contact = encodeURIComponent(document.getElementById('contact').value);
	var description = encodeURIComponent(document.getElementById('description').value);
	var travail = encodeURIComponent(document.getElementById('travail').value);
	xhr.onreadystatechange = function() {
		if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
			document.getElementById('test_ajax').innerHTML = xhr.responseText;
		}
	};
 
	xhr.open("POST", "update_line.php", true);
	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xhr.send("ident="+ident+"&contact="+contact+"&description="+description+"&travail="+travail);
 
} | 
Partager