ianxm
ianxm

Reputation: 81

Haxe JS Http.requestUrl fails with InvalidAccessError

In haxe/js, synchronous http requests fail. For example, this

haxe.Http.requestUrl("http://www.anyurl.com");

results in this error on Firefox:

InvalidAccessError: XMLHttpRequest.responseType setter: synchronous XMLHttpRequests do not support timeout and responseType

It looks like the haxe/js http implementation sets responseType here.

Is there a workaround?

Upvotes: 0

Views: 222

Answers (2)

YellowAfterlife
YellowAfterlife

Reputation: 3202

You may add a copy of HttpJs in your project and tweak it as you need to, but - as people have already pointed out - synchronous requests freeze the entire web page for the duration and have been deprecated for years due to this.

Upvotes: 1

Andrew
Andrew

Reputation: 1282

https://api.haxe.org/haxe/http/HttpBase.html

This class can be used to handle Http requests consistently across platforms. There are two intended usages:

  • call haxe.Http.requestUrl(url) and receive the result as a String (only available on sys targets)
  • create a new haxe.Http(url), register your callbacks for onData, onError and onStatus, then call request().

Example: https://try.haxe.org/#1E28AD28

Upvotes: 3

Related Questions