I want to call a php file on my server to provide a weather service. When I'm running in hosted mode, response.getStatusCode() gives 0 (zero). Is there a way to make this work in hosted mode?
public class IMFPanelWeather extends Composite { private VerticalPanel table = new VerticalPanel(); private HTML mIcon = new HTML(); private HTML mConditions = new HTML(); private HTML mTemperature = new HTML(); private HTML mHumidity = new HTML(); private HTML mClouds = new HTML(); public IMFPanelWeather() { callServerPage(); table.add(mIcon); table.add(mConditions); table.add(mTemperature); table.add(mHumidity); table.add(mClouds); initWidget(table); } private void callServerPage() { RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode("http://www.myserver.com/weather.php5")); try { builder.sendRequest(null , new RequestCallback() { public void onError(Request request, Throwable exception) { requestFailed((RequestException)exception); } public void onResponseReceived(Request request, Response response) { if (200 == response.getStatusCode()) { try { // The response was successful JSONValue jsonValue = JSONParser.parse(response.getText()); JSONArray jsonArray = jsonValue.isArray(); if (jsonArray != null) { updateTable(jsonArray); } else { throw new JSONException(); } } catch (Exception e) { // There has been a problem on the server. mConditions.setHTML("No data"); } } } }); }catch(RequestException e) { requestFailed(e); } } private void requestFailed(RequestException pException) { mConditions.setHTML("Request failed"); System.out.println("Weather request failed."); } } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-toolkit@googlegroups.com To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en -~----------~----~----~----~------~----~------~--~---