Browse Source

Commencé l'AJAX. Flemme de bosser donc je commit.

Brendan Abolivier 9 years ago
parent
commit
6f4e7e38e5
4 changed files with 53 additions and 1 deletions
  1. 3
    1
      web/api/controller/questions.php
  2. 41
    0
      web/index.htm
  3. 5
    0
      web/jquery-1.11.3.min.js
  4. 4
    0
      web/jquery-2.1.4.min.js

+ 3
- 1
web/api/controller/questions.php View File

@@ -2,6 +2,8 @@
2 2
 
3 3
 $categoriesObj = Categorie::randSelect();
4 4
 $categories = array();
5
+$i = 0;
5 6
 foreach($categoriesObj as $categorie) {
6
-	array_push($categories, $categorie->getArray());
7
+	$i++;
8
+	$categories["cat$i"] = $categorie->getArray();
7 9
 }

+ 41
- 0
web/index.htm View File

@@ -0,0 +1,41 @@
1
+<!doctype html>
2
+<html>
3
+  <head>
4
+    <title>fqsdhgfqjlsghoesf</title>
5
+    <meta charset="utf-8" />
6
+    <script src="jquery-1.11.3.min.js"></script>
7
+  </head>
8
+  <body>
9
+    <div id="yolo"></div>
10
+    <input type="submit" id="refresh" value="Refresh" />
11
+    <script type="text/javascript">
12
+      $("#refresh").click(function() {
13
+        $.ajax({
14
+          url: "./api/",
15
+          dataType: 'json',
16
+          success: function(data) {
17
+            $("#yolo").html(JSON.stringify(data));
18
+          }
19
+        });
20
+      });
21
+/*      $(document).ready(function() {
22
+        $.ajax({
23
+          url: "./api/",
24
+          dataType: 'json',
25
+          success: function(data) {
26
+            //cat
27
+            var array = [];
28
+            array[data.cat1.nom_cat] = [];
29
+            data.cat1.themes.forEach(function(row) {
30
+              array[data.cat1.nom_cat].push(row);
31
+            });
32
+            array.forEach(function(row) {
33
+              $("#yolo").append("<strong>"+row);
34
+            });
35
+            $("#yolo").html(JSON.stringify(data));
36
+          }
37
+        });
38
+      });*/
39
+    </script>
40
+  </body>
41
+</html>

+ 5
- 0
web/jquery-1.11.3.min.js
File diff suppressed because it is too large
View File


+ 4
- 0
web/jquery-2.1.4.min.js
File diff suppressed because it is too large
View File