Browse Source

removed JSONP

Maurits van der Schee 8 years ago
parent
commit
c6a9465d9a
1 changed files with 9 additions and 5 deletions
  1. 9
    5
      examples/client.html

+ 9
- 5
examples/client.html View File

@@ -2,12 +2,16 @@
2 2
 <head>
3 3
 <script src="../lib/php_crud_api_transform.js"></script>
4 4
 <script>
5
-function callback(jsonObject) {
6
-  jsonObject = php_crud_api_transform(jsonObject);
7
-  document.getElementById('output').innerHTML = JSON.stringify(jsonObject, undefined, 4);
8
-}
5
+var xhttp = new XMLHttpRequest();
6
+xhttp.onreadystatechange = function() {
7
+  if (this.readyState == 4 && this.status == 200) {
8
+    jsonObject = php_crud_api_transform(JSON.parse(this.responseText));
9
+    document.getElementById('output').innerHTML = JSON.stringify(jsonObject, undefined, 4);
10
+  }
11
+};
12
+xhttp.open("GET", "http://localhost:8000/blog.php/posts?include=categories,tags,comments&filter=id,eq,1", true);
13
+xhttp.send();
9 14
 </script>
10
-<script src="http://localhost/api.php/posts?include=categories,tags,comments&filter=id,eq,1&callback=callback" defer="defer"></script>
11 15
 </head>
12 16
 <body>
13 17
 <pre id="output"></pre>

Loading…
Cancel
Save