VanillaJS Ajax Web Component
Install the component using Bower:
$ bower install ajax-element --save
Or download as ZIP.
-
Import Web Components' polyfill:
<script src="bower_components/webcomponentsjs/webcomponents.min.js"></script>
-
Import Custom Element:
<link rel="import" href="bower_components/ajax-element/src/ajax-element.html">
-
Listen for Events:
<script> document.getElementById('myID').addEventListener('ajaxElementSuccess', function (event) { document.getElementById('anotherID').textContent = event.detail.data; }); document.getElementById('myID').addEventListener('ajaxElementError', function (event) { document.getElementById('anotherID').textContent = event.detail.data; }); </script>
-
Start using it!
<ajax-element url="http://www.example.com"></ajax-element>
Attribute | Options | Default | Description |
---|---|---|---|
url |
string | `` | The Request URL. |
type |
string | GET |
The Request Method. |
datatype |
string | `` | Set to json to parse response as JSON. |
data |
string | `` | Set to serialized data to send with POST requests. |
##TODO
- Promises
- State Indicators
- Mock Server for Demos
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -m 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
For detailed changelog, check Releases.