Skip to content
Browse files

+ iframe/json section

  • Loading branch information...
1 parent b9ff25b commit 7db43f365f20b81182e77af8735c067808de0667 @RubaXa RubaXa committed Oct 17, 2013
Showing with 68 additions and 6 deletions.
  1. +35 −3 README.md
  2. +31 −1 README.ru.md
  3. +1 −1 server/ctrl.php
  4. +1 −1 statics/docs.json
View
38 README.md
@@ -50,14 +50,14 @@ If you need a CORS, then edit the `crossdomain.xml` and put it in the root of re
<a name="FileAPI.getFiles"></a>
### getFiles(input`:HTMLInputElement|Event|$.Event`)`:Array`
-Get files from `input` element or `event` object, also support `jQuery`.
+Retrieve file list from `input` element or `event` object, also support `jQuery`.
* input — `HTMLInputElement`, `change` and `drop` event, `jQuery` collection or `jQuery.Event`
```js
var el = document.getElement('my-input');
FileAPI.event.on(el, function (evt/**Event*/){
- // Get files from input
+ // Retrieve file list
var files = FileAPI.getFiles(el);
// or event
@@ -1123,12 +1123,42 @@ Submit Query
<a name="server"></a>
## Server settings
+<a name="server.iframe"></a>
+### IFrame/JSONP
+Example ctrl.php.
+
+```php
+<?php
+ include './FileAPI.class.php';
+
+ if( strtoupper($_SERVER['REQUEST_METHOD']) == 'POST' ){
+ // Retrieve File List
+ $files = FileAPI::getFiles();
+
+ // ... your logic
+
+ // JSONP callback name
+ $jsonp = isset($_REQUEST['callback']) ? trim($_REQUEST['callback']) : null;
+
+ // Server response: "HTTP/1.1 200 OK"
+ FileAPI::makeResponse(array(
+ 'status' => FileAPI::OK
+ , 'statusText' => 'OK'
+ , 'body' => array('count' => sizeof($files)
+ ), $jsonp);
+ exit;
+ }
+?>
+```
+
+---
+
<a name="server.CORS"></a>
### CORS
Enable CORS.
```php
-<?
+<?php
// Permitted types of request
header('Access-Control-Allow-Methods: POST, OPTIONS');
@@ -1148,6 +1178,7 @@ Enable CORS.
if( $_SERVER['REQUEST_METHOD'] == 'POST' ){
// ...
}
+?>
```
---
@@ -1177,6 +1208,7 @@ All the other codes - fatal error, user's involvement is recommend.
---
+
<a name="buttons.examples"></a>
## Buttons examples
View
32 README.ru.md
@@ -1106,12 +1106,42 @@ Submit Query
<a name="server"></a>
## Server settings
+<a name="server.iframe"></a>
+### IFrame/JSONP
+Пример ctrl.php.
+
+```php
+<?php
+ include './FileAPI.class.php';
+
+ if( strtoupper($_SERVER['REQUEST_METHOD']) == 'POST' ){
+ // Получим список файлов
+ $files = FileAPI::getFiles();
+
+ // ... ваша логика
+
+ // JSONP callback name
+ $jsonp = isset($_REQUEST['callback']) ? trim($_REQUEST['callback']) : null;
+
+ // Ответ сервера: "HTTP/1.1 200 OK"
+ FileAPI::makeResponse(array(
+ 'status' => FileAPI::OK
+ , 'statusText' => 'OK'
+ , 'body' => array('count' => sizeof($files)
+ ), $jsonp);
+ exit;
+ }
+?>
+```
+
+---
+
<a name="server.CORS"></a>
### CORS
Включение CORS.
```php
-<?
+<?php
// Permitted types of request
header('Access-Control-Allow-Methods: POST, OPTIONS');
View
2 server/ctrl.php
@@ -21,7 +21,7 @@
if( strtoupper($_SERVER['REQUEST_METHOD']) == 'POST' ){
- $files = FileAPI::getFiles(); // get files from request
+ $files = FileAPI::getFiles(); // Retrieve File List
$images = array();
View
2 statics/docs.json
1 addition, 1 deletion not shown because the diff is too large. Please use a local Git client to view these changes.

0 comments on commit 7db43f3

Please sign in to comment.
Something went wrong with that request. Please try again.