I'm new in gwt and new to using Firebug. MY gwt version is 2.0.0. using eclipse and WAMP. my IIS is stoped to run WAMP apache. I run my program on firefox
I have valid json result from tesdb3.php located in "http://localhost/phpmyadmin/tesdb3/datauser.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 error in json or Java code.
Why response.getText
is empty? Why I can't get any json result even a single character?
Please help me. already 2 months I try to solve this with many source type and I can't get a single result.
This is my datauser.php
header('Content-type: application/json; charset=UTF-8');
header('Cache-Control: no-cache');
header('Pragma: no-cache');
$link = mysql_connect("localhost", "root", "")
or die("Could not connect : " . mysql_error());
mysql_select_db("tesku1") or die("Could not select database" . mysql_error());
$query = "select * from tabel1";
$result = mysql_query($query);
$jumlah_data = mysql_num_rows($result);
echo '[';
for ($i=0; $i<=count($result); $i++){
$row = mysql_fetch_array($result);
echo '{';
echo "\"kode\":\"$row[kode]\",";
echo "\"nama\":\"$row[nama]\"";
if ($i==count($result)){
echo '}';
}else
echo '},';
}
echo ']';
mysql_free_result($result);