https://github.com/splix/tijax
jQuery-like Http wrapper for Appcelerator Titanium
https://github.com/splix/tijax
Last synced: over 1 year ago
JSON representation
jQuery-like Http wrapper for Appcelerator Titanium
- Host: GitHub
- URL: https://github.com/splix/tijax
- Owner: splix
- License: other
- Created: 2011-07-03T15:00:49.000Z (almost 15 years ago)
- Default Branch: master
- Last Pushed: 2011-07-15T18:31:07.000Z (almost 15 years ago)
- Last Synced: 2024-04-16T10:52:44.628Z (about 2 years ago)
- Language: JavaScript
- Homepage:
- Size: 92.8 KB
- Stars: 9
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE.txt
Awesome Lists containing this project
README
Tijax - http wrapper for Appcelerator Titanium
==========================================================
Tijax is a jQuery inspired http wrapper for Appcelerator Titanium.
Version: 0.3
Examples
--------
Download and put `tijax.js` into your's Resource directory, and then:
```javascript
Ti.include('tijax.js');
// ....
Tijax.get({
url: 'http://example.com/url/to/get.json',
data: {
param1: 'value',
param2: 'value'
},
success: function(data, status, http) {
Ti.API.info('Got it ' + JSON.stringify(data));
},
error: function(http, status) {
Ti.API.error('Failed');
},
complete: function(http, status) {
Ti.API.info('Complete');
}
});
```
or download file:
```javascript
Ti.include('tijax.js');
// ....
Tijax.download({
url: 'http://example.com/test.jpg',
file: targetFile,
success: function() {
Ti.API.debug("Image have downloaded into " + targetFile.nativePath);
}
});
```
file from `http://example.com/test.jpg` will be downloaded into local file `targetFile` (must be `Ti.Filesystem.File`)
How to use
----------
Methods:
* get - `Tijax.get`
* post - `Tijax.post`
* download - `Tijax.download`
Options:
* url - url for request
* data - data to be sent (map of strings)
* timeout - time in millisecond (default is 10000 = 10 seconds)
* headers - headers for request (map of strings)
* success - a function to be called if the request successed. Arguments:
* `data` - map, parsed JSON response
* `http` - used Ti.Network.HTTPClient
* error - a function to be called if the request failed. Arguments:
* `http` - used Ti.Network.HTTPClient
* `status` - request string, as string with one of following value: forbidden, notfound, notallowed, error
* `body` - response body, as text
* complete - a function to be called when the request finished (after success and error callbacks are executed). Arguments:
* `http` - used Ti.Network.HTTPClient
* `status` - status of request, values: value: forbidden, notfound, notallowed, error or success
License
-------
Licensed under the Apache License, Version 2.0
Questions?
----------
Have any questions? Contact me: igor@artamonov.ru