创建对象
private final RequestBuilder requestBuilder =
new RequestBuilder( RequestBuilder.GET, "search-results.js" );
请求
requestBuilder.sendRequest(null, new RequestCallback(){
public void onError(Request request, Throwable exception) {
displayRequestError(exception.toString());
resetSearchButtonCaption();
}
public void onResponseReceived(Request request, Response response) {
String responseText = response.getText(); //得到值
try {
JSONValue jsonValue = JSONParser.parse(responseText); //转为json数据
//操作数据
JSONArray jsonArray;
JSONObject jsonObject;
JSONString jsonString;
if ((jsonArray = jsonValue.isArray()) != null) {
}
} else if ((jsonObject = jsonValue.isObject()) != null) {
} else if ((jsonString = jsonValue.isString()) != null) {
}
} catch (JSONException e) {
System.out.println(ex.toString());
}
}
});