Bonjour bonsoir,

j'ai ce code ci:
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
$(document).ready(function() {
 
if (navigator.geolocation){
    navigator.geolocation.getCurrentPosition(function(position){
 
            var userLat = position.coords.latitude;
            var userLong = position.coords.longitude;
            console.log( userLong);
            console.log( userLat);
 
            $.ajax({
              type: 'POST',
 
              url: 'index.php',
 
              data: {
              userLat : userLat,
              userLong : userLong
              },
              success: function(data)
                {
                  console.log(data);
                    alert("boom boom tam tam!");
 
                }
 
            });
 
    });
}else{
    console.log("Browser doesn't support geolocation!");
}});
Rien de bien compliqué à priorie, pourtant ce code m'affiche tout le contenu HTML de la page, dans ma variable data. Et quand je précise le type de données (dataType: 'json'), alors la fonction success n'affiche plus rien.

Quelqu'un saurait-il ce qui cloche ?

Merci d'avance