Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stisa/ajax
Ajax wrapper for nim js backend
https://github.com/stisa/ajax
ajax hacktoberfest json nim nim-lang wrapper xmlhttprequest
Last synced: about 2 months ago
JSON representation
Ajax wrapper for nim js backend
- Host: GitHub
- URL: https://github.com/stisa/ajax
- Owner: stisa
- License: mit
- Created: 2017-03-05T18:54:16.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2021-10-28T22:27:47.000Z (about 3 years ago)
- Last Synced: 2023-09-05T11:41:32.608Z (over 1 year ago)
- Topics: ajax, hacktoberfest, json, nim, nim-lang, wrapper, xmlhttprequest
- Language: Nim
- Homepage:
- Size: 22.5 KB
- Stars: 21
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Ajax
----
[![nimble](https://raw.githubusercontent.com/yglukhov/nimble-tag/master/nimble_js.png)](#)Basic wrapper for ajax, for the javascript backend of [nim](https://nim-lang.org)
[Examples](http://stisa.space/ajax)[Generated Docs](http://stisa.space/ajax/ajax.html)
Example: Alert the content of a file named `test.html`
```nim
import dom
import ajaxproc makeRequest(url:cstring) =
var httpRequest = newXMLHttpRequest()if httpRequest.isNil:
window.alert("Giving up :( Cannot create an XMLHTTP instance")
return
proc alertContents(e:Event) =
if httpRequest.readyState == rsDONE:
if httpRequest.status == 200:
window.alert(httpRequest.responseText)
else:
window.alert("There was a problem with the request.")
httpRequest.onreadystatechange = alertContents
httpRequest.open("GET", url);
httpRequest.send();document.getElementById("ajaxButton").onclick = proc(e:Event) =
makeRequest("test.html")
```