Bonjour
je suis debutant , je veux que j'ajoute un article les autres article affiches dans meme page plus le derniere article sans actualiser la page merci

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function getAJAX(page){
var xmlhttp;
if (window.XMLHttpRequest)
  xmlhttp=new XMLHttpRequest();
 
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
 if (!xmlhttp) 
    xmlhttp=new ActiveXObject("Msxml2.XMLHTTP.3.0");
  if (!xmlhttp) 
    xmlhttp=new ActiveXObject("Msxml2.XMLHTTP.6.0");
  }
  xmlhttp.onreadystatechange =function(){
     if (xmlhttp.readyState < 4) 
 
document.getElementById("jax").innerHTML='<img src ="1.gif" border=0 />';
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    document.getElementById("jax").innerHTML=xmlhttp.responseText;
    }
 
xmlhttp.open("GET",page,true);
xmlhttp.send();
}
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
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
<?php require_once "functions.php"; 
 
        if(isset($_POST['title']) && isset($_POST['content'])) {
                add_post($_POST['title'], $_POST['content']);
                //header("Location:index.php");die();
        }
        
?>
<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Posts</title>
 
	<script type="text/javascript">
...
</script>
</head>
<body>
<h1>Add</h1>
	<form action="#" method="post">
		Title:
		<input type="text" name="title"> <br>
 
		Content:
		<input name="content" type="text"> <br>
		<!--<input type="submit" value="Add">-->
			<button type="submit" value="add" onclick="getAJAX('index.php')">Change Content</button>
	</form>
 
	<div id="jax"></div>
</body>
</html>