Bonjour ;
voilà j'utilise le frmaework codeigniter et je teste la possibilité de mettre Ajax avec ; ce framework est basé sur le modèle : MVC

dans ma vue j'ai çà :

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
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
 
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>Ajax essai</title>
     <script type = "text/javascript">
 
 function showUser(str)
 {
 var xmlhttp;
 if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }  
 if (window.XMLHttpRequest)
 {// code for IE7+, Firefox, Chrome, Opera, Safari
 xmlhttp = new XMLHttpRequest();
 }
 else
 {// code for IE6, IE5
 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
 }
 xmlhttp.onreadystatechange = function()
 {
 if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
    }
 }
 //xmlhttp.open("GET", "ajaxcontrolleur.php?q="+str, true);
 xmlhttp.open("GET", "ajaxcontrolleur?q="+str, true);
 xmlhttp.send();
 }
 </script>
</head>
<body>
 
<form>
<select name="users" onchange="showUser(this.value)">
<option value="">Select a person:</option>
<option value="1">Peter Griffin</option>
<option value="2">Lois Griffin</option>
<option value="3">Glenn Quagmire</option>
<option value="4">Joseph Swanson</option>
</select>
</form>
<br />
<div id="txtHint"><b>Person info will be listed here.</b></div>
 
</body>
</html>
dans mon controlleur :

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
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
 
<?php
/**
 * @property CI_DB_active_record $db
 * @property CI_DB_forge $dbforge
 * @property CI_Benchmark $benchmark
 * @property CI_Calendar $calendar
 * @property CI_Cart $cart
 * @property CI_Config $config
 * @property CI_Controller $controller
 * @property CI_Email $email
 * @property CI_Encrypt $encrypt
 * @property CI_Exceptions $exceptions
 * @property CI_Form_validation $form_validation
 * @property CI_Ftp $ftp
 * @property CI_Hooks $hooks
 * @property CI_Image_lib $image_lib
 * @property CI_Input $input
 * @property CI_Language $language
 * @property CI_Loader $load
 * @property CI_Log $log
 * @property CI_Model $model
 * @property CI_Output $output
 * @property CI_Pagination $pagination
 * @property CI_Parser $parser
 * @property CI_Profiler $profiler
 * @property CI_Router $router
 * @property CI_Session $session
 * @property CI_Sha1 $sha1
 * @property CI_Table $table
 * @property CI_Trackback $trackback
 * @property CI_Typography $typography
 * @property CI_Unit_test $unit_test
 * @property CI_Upload $upload
 * @property CI_URI $uri
 * @property CI_User_agent $user_agent
 * @property CI_Validation $validation
 * @property CI_Xmlrpc $xmlrpc
 * @property CI_Xmlrpcs $xmlrpcs
 * @property CI_Zip $zip
 */
 
 
class Ajaxcontrolleur extends CI_Controller 
{
 
    public function __construct() 
    {
        parent::__construct();
    }
 
 
    public function index() 
    {
        
       //  echo 'je suis la ';
         /* on recupere la valeur du select */
       //  $q = $_GET["q"];
        
       $this->input->get('q');
        
        /* on le cherche dans la base */
        $data['infos'] = $this->modelajax->cherche($q);
        
        /* on charge vers la vue */
       $this->load->view('ajax_view',$data);
        
    //     var_dump($data); exit ;
        
    }
 
 
     
}
 
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
?>
et dans mon modele

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
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
 
 
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>essai ajax</title>
</head>
<body>
 
         <table border="1">
             <tr>
                 <th>id</th>
                 <th>titre</th>
                 <th>contenu</th>
             </tr>
 
 
        <?php if ($infos!= null):
         foreach ($infos as $r):?>
 
             <tr>
                 <td><?php echo $r['id']; ?></td>
                 <td><?php echo $r['titre']; ?></td>
                 <td><?php echo $r['contenu']; ?></td>
 
             </tr>
 
 
 
 
 
 
 
 
    <?php endforeach;endif; ?>
 
             </table>
 
 
 
 
 
 
 
 
 
 
 
</body>
</html>
bien sur le problème vient sans doute de la récupération du paramètre via get
j'ai essayé ces 2 codes mais çà ne marche pas
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
 
  //  $q = $_GET["q"];
 
       $this->input->get('q');
est ce que quelqu'un a une idée ??

merci