stdweb
stdweb copied to clipboard
how to use XmlHttpRequest?
let xhr = XmlHttpRequest::new();
xhr.open("https://google.com");
xhr.add_event_listener( move |e: ResourceLoadEvent| {
console!(log, "{:?}",e);
});
xhr.send();
Uncaught RuntimeError: unreachable
at __rust_start_panic (wasm-function[239]:1)
at rust_panic (wasm-function[235]:30)
at std::panicking::rust_panic_with_hook::ha79707b92e24cb8e (wasm-function[230]:444)
at std::panicking::continue_panic_fmt::hececa9f14e24d3a2 (wasm-function[228]:122)
at std::panicking::begin_panic_fmt::h8e192d1fd82051f9 (wasm-function[229]:95)
at _$LT$stdweb..webcore..newtype..Newtype$LT$$LP$stdweb..webcore..serialization..FunctionTag$C$$u20$$LP$A12$C$$RP$$RP$$C$$u20$F$GT$$u20$as$u20$stdweb..webcore..serialization..FuncallAdapter$LT$F$GT$$GT$::funcall_adapter::hcb24e0117d77036b (wasm-function[42]:946)
at Object.Module.STDWEB_PRIVATE.dyncall (http://[::1]:8000/carrier-web.js:416:40)
at XMLHttpRequest.output (http://[::1]:8000/carrier-web.js:142:35)
The error could definitely be better here, however the problem you have here is that you're using the wrong event type. (: You need to use ProgressLoadEvent.
ah, i wanted to know when the thing is Done. I'm polling ready_state() in ReadyStateChangeEvent now