update kajax.nim to use the 'kxi' context too
This commit is contained in:
parent
b3fba429ad
commit
28c4f4b76a
1 changed files with 9 additions and 6 deletions
|
|
@ -7,10 +7,11 @@ import karax
|
|||
|
||||
proc ajax(meth, url: cstring; headers: openarray[(cstring, cstring)];
|
||||
data: cstring;
|
||||
cont: proc (httpStatus: int; response: cstring)) =
|
||||
cont: proc (httpStatus: int; response: cstring);
|
||||
kxi: KaraxInstance = kxi) =
|
||||
proc contWrapper(httpStatus: int; response: cstring) =
|
||||
cont(httpStatus, response)
|
||||
redraw()
|
||||
redraw(kxi)
|
||||
|
||||
type
|
||||
HttpRequest {.importc.} = ref object
|
||||
|
|
@ -39,12 +40,14 @@ proc ajax(meth, url: cstring; headers: openarray[(cstring, cstring)];
|
|||
|
||||
proc ajaxPost*(url: cstring; headers: openarray[(cstring, cstring)];
|
||||
data: cstring;
|
||||
cont: proc (httpStatus: int, response: cstring)) =
|
||||
ajax("POST", url, headers, data, cont)
|
||||
cont: proc (httpStatus: int, response: cstring);
|
||||
kxi: KaraxInstance = kxi) =
|
||||
ajax("POST", url, headers, data, cont, kxi)
|
||||
|
||||
proc ajaxGet*(url: cstring; headers: openarray[(cstring, cstring)];
|
||||
cont: proc (httpStatus: int, response: cstring)) =
|
||||
ajax("GET", url, headers, nil, cont)
|
||||
cont: proc (httpStatus: int, response: cstring);
|
||||
kxi: KaraxInstance = kxi) =
|
||||
ajax("GET", url, headers, nil, cont, kxi)
|
||||
|
||||
proc toJson*[T](data: T): cstring {.importc: "JSON.stringify".}
|
||||
proc fromJson*[T](blob: cstring): T {.importc: "JSON.parse".}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue