Bonjour à toutes et tous,

je voulais parser un fichier JSON avec HTML, le fichier est le suivant:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
{
"menu":[
    {"id": "TN", "value": "ar"} ,
    {"id": "FR", "value": "fr"} ,
    {"id": "GB", "value": "en"} ,
    {"id": "US", "value": "en"} 
],
}
voici la page HTML que je l'utilise:

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
<!DOCTYPE html><!--HTML5 doctype-->
<html>
<head>
	<title>Your New Application</title>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0" />
	<style type="text/css">
		/* Prevent copy paste for all elements except text fields */
		*  { -webkit-user-select:none; -webkit-tap-highlight-color:rgba(255, 255, 255, 0); }
		input, textarea  { -webkit-user-select:text; }
		body { background-color:white; color:black }
	</style>
 
	<script type="text/javascript">
		/* This code is used to run as soon as Intel activates */
		var onDeviceReady=function(){
		//hide splash screen
		intel.xdk.device.hideSplashScreen();
		};
		document.addEventListener("intel.xdk.device.ready",onDeviceReady,false);
	</script>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script>
 
        //When DOM loaded we attach click event to button
        $(document).ready(function() {
 
            //after button is clicked we download the data
            $('.button').click(function(){
 
                //start ajax request
                $.ajax({
                    url: "pays.json",
                    //force to handle it as text
                    dataType: "text",
                    success: function(data) {
 
                        //data downloaded so we call parseJSON function 
                        //and pass downloaded data
                        var json = $.parseJSON(data);
                        //now json variable contains data in json format
                        //let's display a few items
                        $('#results').html('Country: ' + json.menu.id[0] + '<br />Language: ' + json.menu.value[0]);
                    }
                });
            });
        });
    </script>
 
</head>
<body>
    <a href="pays.json" target="_blank">Open JSON file</a><br />
    <input type="button" value="Get and parse JSON" class="button" />
    <br />
    <span id="results"></span>
</body>
</html>
Le problème lorsque j'exécute, je ne reçoit rien en cliquant sur le bouton "Get and parse JSON". Je me demande comment faire pour afficher le contenu de mon fichier JSON.

Merci!