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"}]}
Ben xml eklemek
<inherits name='com.google.gwt.json.JSON'/>
<inherits name="com.google.gwt.http.HTTP" />
sonra ben bu kod ile GWT onu göstermeye çalışacağım.
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
Benim soru:
Neden yanıt durum kodu 0 ve yanıt durumu metni 'Tamam' olduğunu? json veya Java kodunda hata yoktu.
Neden response.getText
boş? Ben herhangi bir json sonuç alamayan neden hatta tek bir karakter?
Lütfen bana yardımcı olun. Zaten 2 ay ben çok kaynak türü ile bu çözmeye çalışın ve ben tek bir sonuç alınamıyor.
Bu benim datauser.php
olduğunu
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);