Saturday, February 18, 2017

Re: Browser.getWindow().newXMLHttpRequest()

Pretty old thread, but... to fix the "is not a function" error you need to add the GWT compiler param "-generateJsInteropExports".

On Thursday, November 17, 2016 at 11:32:30 AM UTC+1, P.G.Taboada wrote:
Thanks, this is what I was missing. 
I tried to use elemental, but could neither find formdata nor append...

I am having troubles with the event listeners:

final XMLHttpRequest xhr = Browser.getWindow().newXMLHttpRequest();
xhr.open("POST", "/upload");
xhr.setOnprogress(evt -> GWT.log("" + evt));
xhr.setOnabort(evt -> GWT.log("" + evt));
xhr.setOnerror(evt -> GWT.log("" + evt));
xhr.setOnreadystatechange(evt -> {
if (xhr.getReadyState() == XMLHttpRequest.DONE) {
try {
GWT.log("Received http response for request ");
String text = xhr.getResponseText();
if (text == null || text.isEmpty()) {
messageUi.setInnerText("no response");
} else {
messageUi.setInnerText(text);
}
} catch (Throwable e) {
GWT.log("Error", e);
}
}
});
final JsFormData formData = createFormData();
append(formData, "someFile", file);
xhr.send(formData);


I get 4 times

JsEventListener.java:42 Uncaught TypeError: this$static_0_g$.handleEvent is not a function

Any idea?

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment