json parser empty result
Posted
by graybow
on Stack Overflow
See other posts from Stack Overflow
or by graybow
Published on 2010-06-07T09:42:39Z
Indexed on
2010/06/07
9:52 UTC
Read the original article
Hit count: 207
gwt
I'm new in gwt and new in using firebug.I have valid json result from tesdb3.php
{"item": [{"kode":"002","nama":"bambang gentolet"},
{"kode":"012","nama":"Algiz"}]}
I add the xml with
inherits name='com.google.gwt.json.JSON'/
inherits name="com.google.gwt.http.HTTP" /
then i try to show it in the gwt with this code.
public class Tesdb3 implements EntryPoint {
String url= "http://localhost/phpmyadmin/tesdb3/datauser.php";
public void LoadData() throws RequestException{
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(url));
builder.sendRequest(null, new RequestCallback(){
@Override
public void onError(Request request, Throwable exception) {
Window.alert("error " + exception);
}
public void onResponseReceived(Request request,
Response response) {
if (200 == response.getStatusCode()) {
Window.alert("ok -" + response.getText() + "-" + response.getStatusCode());
} else {
Window.alert("error2 -" + response.getText()+ response.getStatusText() + "-" + response.getStatusCode());
}
}
});
}
public void onModuleLoad() {
try {
LoadData();
} catch (RequestException e) {
e.printStackTrace();
}
}
}
I run it in development mode. not hosted mode.
My code didn't show any error. But the result in window alert is "error2 --OK-0".
result Net from firebug is 7 request:
get Tesdb3.html?gwt.codeserv = 200ok
get Tesdb3.css = 200ok
get tesdb3.nocache.js = 200ok
get hosted.html?tesdb3 = aborted
get standard.css = 304 not modified
get hosted.html?tesdb3 = 403 not modified
get datauser.php = 200ok
my question is:
Why the response status code is 0, and the response status text is 'OK'? there was no eror in json or java code.
why response.getText
is empty? Why i can't get any json result even a single character?
© Stack Overflow or respective owner