Bonjour à tous,

Pour un site dev en php j'intègre petit à petit du jquery et je suis face à un problème. J'ai une fonction javascript qui en appelle une autre. La 2ème est le résultat d'une requête php qui me renvoie bien des données mais dans ma fonction principale je n'arrive pas à affiche le récupérer le résultat. Ca sera peut être plus clair avec le code :

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
   publics.getOppors = function (bpcnum, bpaadd, tsccod, tsccod1, tsccod2, rep, datedeb, datefin) {
    $.ajax({
      url: privates.url,
      cache: false,
      type: "GET",
      dataType: "json",
      data: {
        a: 'getoppors',
        bpcnum: bpcnum,
        bpaadd: bpaadd,
        tsccod: tsccod,
        tsccod1: tsccod1,
        tsccod2: tsccod2,
        rep: rep,
        datedeb: datedeb,
        datefin: datefin,
        j:1
      },
      success: function(data) {
        $.each(data, function (key, value) {
          var oppornum = data[key]['oppor'];
          var html = '<tr>';
          if(data[key]['oppor'] == '') {
            html = html + '<td class="colhead nowrap" colspan="2">Hors codes promos</td>';
          } else {
            var oppor = publics.getOppor(oppornum);
            console.log('oppo : ' + oppor);
// oppor est toujours undefined alors qu'il y a bien un résultat :(
            html = html + '<td class="colhead nowrap" colspan="2"><i>' + oppornum + '</i> - ' + oppor + '</td>';
          }
          html = html + '</tr>';
          console.log(html);
        });
      },
      error: function(){
        console.log('no data');
      }
    });
  }
 
  publics.getOppor = function (oppor) {
    $.ajax({
      url: privates.url,
      cache: false,
      type: "GET",
      dataType: "json",
      data: {
        a: 'getoppor',
        oppor: oppor,
        j: 1
      },
      success: function(data) {        
        return(data);
      },
      error: function() {
        console.log('pas d oppor');
      }
    });
La partie php
Code php : 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
	  public function getOppor() {
			$oppor = $this->purge($_GET['oppor']);
 
	    if(!empty($oppor)) {
	      $oppor = $this->database->get('oppor',
	        [
	          'oppdes'
	        ], [
	          'oppnum' => $oppor
	        ]);
	      echo json_encode($oppor['oppdes']);
	    } else {
	      $oppor = $this->database->select('oppor',
	        [
	          'oppnum',
	          'oppdes'
	        ]);
	      echo json_encode($oppor);
	    }
	  }


Est-ce que vous avez une idée de où peut provenir le problème ?
Merci d'avance.