Bonjour
Je continue mes (mes)aventures en php :oops:
Je vais simplifier pour que ce soit clair.
J'ai une classe A qui me permet de communiquer via une socket et faire des accès à un serveur de fichier.
genre :
ensuite j'ai une page test qui affiche dans un tableau les 20 premiers enregistrements du fichierCode:
1
2
3
4
5
6
7
8
9
10
11 <?php class A { function connexion ($serveur,$port){} function ouvre ($fichier) {} function suivant ($identifiant_fichier) {} function precedent ($identifiant_fichier) {} { ?>
genre test.php :
Ca roule jusque làCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1250"> </head> <body> <?php include("classA.php" ); $m=new A(); $m->connexion(); $m->ouvre($monfichier); ?> <table> <?php for($i=0;$i<20;$i++) { m->suivant(); echo "<tr> <td>".m->variable['a']."</td> <td>".m->variable['b']."</td> <td>".m->variable['c']."</td></tr>"; ?> </table> </body> </html>
phase 2 : Mettre un bouton suivant qui affiche les 20 suivants sans rafraichir toute la page d'où l'appel à ajax d'après mon collegue..
J'ai modifié mon test.php en ceci:
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1250"> <script src="testjs.js" type="text/javascript"></script> </head> <body> <?php include("classA.php" ); $m=new A(); $m->connexion(); $m->ouvre($monfichier); session_start(); $_SESSION['monObjet']=$m; ?> <form name="form1" method="post" action="javascript:ModifZone()" > <input name="bouton1" type="submit" value="Suivant"> </form> <table> <div id="lignes"> </div> </table> </body> </html>
Mon collegue m' a pondu un ajax où je ne maitrise pas tout encore
testjs.js :
et le fichier ajax_test.php:Code:
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
34
35 function ModifZone(conn) { xmlhttp=GetXmlHttpObject(); if (xmlhttp==null) { alert ("Your browser does not support AJAX!"); return; } var url="ajax_test.php"; xmlhttp.onreadystatechange=function () { if (xmlhttp.readyState==4) { eval("document.getElementById('lignes').innerHTML = xmlhttp.responseText;"); } } xmlhttp.open("GET",url,true); xmlhttp.send(null); } function GetXmlHttpObject() { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if (window.ActiveXObject) { // code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); } return null; }
Et bien ca ne marche pas :cry:Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 <?php session_start (); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Cache-Control: no-cache"); //session_start(); $m=$_SESSION['monObjet']; $retour=""; for($i=0;$i<50;$i++) { $m->suivant(); $retour.= "<tr> <td>".$m->variable['a']."</td> <td>".$m->variable['b']."</td> <td>".$m->variable['c']."</td> </tr>"; } echo $retour; ?>
J'ai ceci qui s'affiche :
The script tried to execute a method or access a property of an incomplete object
Je comprends que l'objet monObjet n'est pas défini.. En cherchant sur les forums, certains ont ajouté un include avant l'appel à $m=$_SESSION['monObjet'] mais je me retrouve avec la page rechargée dans la table..
Allo maman bobo :aie:
Pouvez vous m'aider Please???? :cry: