You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I try to set an onerror handler on an httpRequest I get a type mismatch.
Here the details. The Nim code is:
import dom
import ajax
proc makeRequest(url:cstring) =
var httpRequest = newXMLHttpRequest()
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.")
proc alertError(e:Event) =
window.alert("There was a FUNDAMENTAL problem with the request.")
httpRequest.onreadystatechange = alertContents
httpRequest.onerror = alertError
httpRequest.open("GET", url);
httpRequest.send();
document.getElementById("ajaxButton").onclick = proc(e:Event) =
makeRequest("test.html")
The full error message of the compiler is:
Error: type mismatch: got <XMLHttpRequest, proc (e: Event){.noSideEffect, gcsafe, locks: 0.}>
but expected one of:
macro `.=`(obj: JsObject; field, value: untyped): untyped
first type mismatch at position: 1
required type for obj: JsObject
but expression 'httpRequest' is of type: XMLHttpRequest
macro `.=`[K: cstring; V](obj: JsAssoc[K, V]; field: untyped; value: V): untyped
first type mismatch at position: 1
required type for obj: JsAssoc[.=.K, .=.V]
but expression 'httpRequest' is of type: XMLHttpRequest
The text was updated successfully, but these errors were encountered:
When I try to set an
onerror
handler on anhttpRequest
I get a type mismatch.Here the details. The Nim code is:
The full error message of the compiler is:
The text was updated successfully, but these errors were encountered: