No description
Find a file
Silvio f06cded6d9
Merge pull request #6 from stisa/#4
add minimal example for #4
2021-10-29 00:27:47 +02:00
docs make docs, example 2017-03-05 20:04:44 +01:00
examples add minimal example for #4 2021-10-29 00:24:27 +02:00
src add onerror handler 2021-10-29 00:03:08 +02:00
templates make docs, example 2017-03-05 20:04:44 +01:00
.gitignore first push, works 2017-03-05 19:57:15 +01:00
ajax.nimble fix to work with nim 1.4, members are now defined in base type 2020-10-24 19:59:22 +11:00
LICENSE first push, works 2017-03-05 19:57:15 +01:00
README.md update readme 2017-03-05 20:31:32 +01:00

Ajax

nimble

Basic wrapper for ajax, for the javascript backend of nim

Examples

Generated Docs

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")