mirror of
https://github.com/stisa/ajax
synced 2026-01-14 16:21:38 +00:00
No description
|
|
||
|---|---|---|
| docs | ||
| examples | ||
| src | ||
| templates | ||
| .gitignore | ||
| ajax.nimble | ||
| LICENSE | ||
| README.md | ||
Ajax
Basic wrapper for ajax, for the javascript backend of nim
Example: Alert the content of a file named test.html
import dom
import ajax
proc 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")
