本文整理了Java中com.google.gwt.xhr.client.XMLHttpRequest.getStatus()
方法的一些代码示例,展示了XMLHttpRequest.getStatus()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLHttpRequest.getStatus()
方法的具体详情如下:
包路径:com.google.gwt.xhr.client.XMLHttpRequest
类名称:XMLHttpRequest
方法名:getStatus
[英]Gets the status code.
See http://www.w3.org/TR/XMLHttpRequest/#the-status-attribute.
[中]获取状态代码。
见http://www.w3.org/TR/XMLHttpRequest/#the-status-attribute。
代码示例来源:origin: libgdx/libgdx
@Override
public void onReadyStateChange (XMLHttpRequest xhr) {
if (xhr.getReadyState() == XMLHttpRequest.DONE) {
if (xhr.getStatus() != 200) {
listener.onFailure();
} else {
listener.onSuccess(xhr.getResponseText());
}
}
}
});
代码示例来源:origin: playn/playn
@Override public void onReadyStateChange(XMLHttpRequest xhr) {
int readyState = xhr.getReadyState();
if (readyState == XMLHttpRequest.DONE) {
int status = xhr.getStatus();
// status code 0 will be returned for non-http requests, e.g. file://
if (status != 0 && (status < 200 || status >= 400)) {
plat.log().error("xhr::onReadyStateChange[" + path + "]" +
"(readyState = " + readyState + "; status = " + status + ")");
result.fail(new Exception("Error getting " + path + " : " + xhr.getStatusText()));
} else {
if (LOG_XHR_SUCCESS) plat.log().debug("xhr::onReadyStateChange[" + path + "]" +
"(readyState = " + readyState +
"; status = " + status + ")");
result.succeed(xhr);
}
}
}
});
代码示例来源:origin: libgdx/libgdx
@Override
public void onReadyStateChange (XMLHttpRequest xhr) {
if (xhr.getReadyState() == XMLHttpRequest.DONE) {
if (xhr.getStatus() != 200) {
listener.onFailure();
} else {
listener.onSuccess(xhr.getResponseText());
}
}
}
});
代码示例来源:origin: io.playn/playn-html
@Override public void onReadyStateChange(XMLHttpRequest xhr) {
int readyState = xhr.getReadyState();
if (readyState == XMLHttpRequest.DONE) {
int status = xhr.getStatus();
// status code 0 will be returned for non-http requests, e.g. file://
if (status != 0 && (status < 200 || status >= 400)) {
plat.log().error("xhr::onReadyStateChange[" + path + "]" +
"(readyState = " + readyState + "; status = " + status + ")");
result.fail(new Exception("Error getting " + path + " : " + xhr.getStatusText()));
} else {
if (LOG_XHR_SUCCESS) plat.log().debug("xhr::onReadyStateChange[" + path + "]" +
"(readyState = " + readyState +
"; status = " + status + ")");
result.succeed(xhr);
}
}
}
});
代码示例来源:origin: libgdx/libgdx
@Override
public void onReadyStateChange (XMLHttpRequest xhr) {
if (xhr.getReadyState() == XMLHttpRequest.DONE) {
if (xhr.getStatus() != 200) {
listener.onFailure();
} else {
Int8Array data = TypedArrays.createInt8Array(xhr.getResponseArrayBuffer());
listener.onSuccess(new Blob(data));
}
}
}
});
代码示例来源:origin: sriharshachilakapati/SilenceEngine
@Override
public void readTextFile(FilePath file, UniCallback<String> onComplete, UniCallback<Throwable> onError)
{
// Create a XMLHttpRequest to load the file into a direct buffer
XMLHttpRequest request = XMLHttpRequest.create();
request.open("GET", file.getAbsolutePath());
// Set to read as default mode and attach a handler
request.setResponseType(XMLHttpRequest.ResponseType.Default);
request.setOnReadyStateChange(xhr ->
{
if (request.getReadyState() == XMLHttpRequest.DONE)
{
if (request.getStatus() == 200)
// Invoke the onComplete handler
onComplete.invoke(request.getResponseText());
else
onError.invoke(new SilenceException("Error fetching the file: " + request.getStatusText()));
}
});
// Send the request
request.send();
}
}
代码示例来源:origin: libgdx/libgdx
@Override
public void onReadyStateChange (XMLHttpRequest xhr) {
if (xhr.getReadyState() == XMLHttpRequest.DONE) {
if (xhr.getStatus() != 200) {
listener.onFailure();
} else {
Int8Array data = TypedArrays.createInt8Array(xhr.getResponseArrayBuffer());
listener.onSuccess(new Blob(data));
}
}
}
});
代码示例来源:origin: sriharshachilakapati/SilenceEngine
@Override
public void readBinaryFile(FilePath file, UniCallback<DirectBuffer> onComplete, UniCallback<Throwable> onError)
{
// Create a XMLHttpRequest to load the file into a direct buffer
XMLHttpRequest request = XMLHttpRequest.create();
request.open("GET", file.getAbsolutePath());
// Set to read as ArrayBuffer and attach a handler
request.setResponseType(XMLHttpRequest.ResponseType.ArrayBuffer);
request.setOnReadyStateChange(xhr ->
{
if (request.getReadyState() == XMLHttpRequest.DONE)
{
if (request.getStatus() == 200)
// Invoke the onComplete handler
onComplete.invoke(new GwtDirectBuffer(request.getResponseArrayBuffer()));
else
onError.invoke(new SilenceException("Error fetching the file: " + request.getStatusText()));
}
});
// Send the request
request.send();
}
代码示例来源:origin: com.google.gwt/gwt-servlet
@Override
public int getStatusCode() {
return xmlHttpRequest.getStatus();
}
代码示例来源:origin: net.wetheinter/gwt-user
@Override
public int getStatusCode() {
return xmlHttpRequest.getStatus();
}
代码示例来源:origin: com.vaadin.external.gwt/gwt-user
@Override
public int getStatusCode() {
return xmlHttpRequest.getStatus();
}
代码示例来源:origin: stackoverflow.com
XMLHttpRequest req = XMLHttpRequest.create();
req.open("HEAD", fileURL);
req.setOnReadyStateChange(new ReadyStateChangeHandler() {
@Override
public void onReadyStateChange(XMLHttpRequest xhr) {
if (xhr.getReadyState() == XMLHttpRequest.DONE) {
if (xhr.getStatus() == 200) {
Window.open(fileURL, winTitle, "");
} else {
// TODO handle other status codes
}
}
}
});
req.send();
代码示例来源:origin: org.atmosphere/atmosphere-gwt-client
@Override
public void run() {
if (xmlHttpRequest != null && read < xmlHttpRequest.getResponseText().length()) {
onReceiving(xmlHttpRequest.getStatus(), xmlHttpRequest.getResponseText());
}
}
};
代码示例来源:origin: com.vaadin.external.atmosphere/atmosphere-gwt-client
@Override
public void run() {
if (xmlHttpRequest != null && read < xmlHttpRequest.getResponseText().length()) {
onReceiving(xmlHttpRequest.getStatus(), xmlHttpRequest.getResponseText());
}
}
};
代码示例来源:origin: com.badlogicgames.gdx/gdx-backend-gwt
@Override
public void onReadyStateChange (XMLHttpRequest xhr) {
if (xhr.getReadyState() == XMLHttpRequest.DONE) {
if (xhr.getStatus() != 200) {
listener.onFailure();
} else {
listener.onSuccess(xhr.getResponseText());
}
}
}
});
代码示例来源:origin: thothbot/parallax
@Override
public void onReadyStateChange (XMLHttpRequest xhr) {
if (xhr.getReadyState() == XMLHttpRequest.DONE) {
if (xhr.getStatus() != 200) {
listener.onFailure();
} else {
listener.onSuccess(xhr.getResponseText());
}
}
}
});
代码示例来源:origin: sriharshachilakapati/SilenceEngine
@Override
public Promise<Boolean> exists()
{
return new Promise<>((resolve, reject) ->
{
XMLHttpRequest request = XMLHttpRequest.create();
request.open("HEAD", getAbsolutePath());
request.setOnReadyStateChange(xhr ->
{
if (request.getStatus() == 404)
resolve.invoke(false);
else if (request.getReadyState() == XMLHttpRequest.DONE && request.getStatus() == 200)
resolve.invoke(true);
});
request.send();
});
}
代码示例来源:origin: com.badlogicgames.gdx/gdx-backend-gwt
@Override
public void onReadyStateChange (XMLHttpRequest xhr) {
if (xhr.getReadyState() == XMLHttpRequest.DONE) {
if (xhr.getStatus() != 200) {
listener.onFailure();
} else {
Int8Array data = TypedArrays.createInt8Array(xhr.getResponseArrayBuffer());
listener.onSuccess(new Blob(data));
}
}
}
});
代码示例来源:origin: thothbot/parallax
@Override
public void onReadyStateChange (XMLHttpRequest xhr) {
if (xhr.getReadyState() == XMLHttpRequest.DONE) {
if (xhr.getStatus() != 200) {
listener.onFailure();
} else {
Int8Array data = TypedArrays.createInt8Array(xhr.getResponseArrayBuffer());
listener.onSuccess(new Blob(data));
}
}
}
});
代码示例来源:origin: org.atmosphere/atmosphere-gwt-client
@Override
public void onReadyStateChange(XMLHttpRequest request) {
if (!aborted) {
switch (request.getReadyState()) {
case XMLHttpRequest.LOADING:
onReceiving(request.getStatus(), request.getResponseText());
if (needPolling()) {
pollingTimer.scheduleRepeating(POLLING_INTERVAL);
}
break;
case XMLHttpRequest.DONE:
onLoaded(request.getStatus(), request.getResponseText());
pollingTimer.cancel();
break;
}
} else {
request.clearOnReadyStateChange();
if (request.getReadyState() != XMLHttpRequest.DONE) {
request.abort();
}
}
}
});
内容来源于网络,如有侵权,请联系作者删除!