I am trying to communicate to a php server from my gwt project.
I already got a GET request to work, however, my POST request doesn't work so far.
Here's my code:
Button synchronize = new Button("synchronize ",
                new ClickHandler() {
                    public void onClick(ClickEvent event) {
                        String myurl = URL
                                .encode("php/test.php");
                        RequestBuilder builder = new RequestBuilder(
                                RequestBuilder.POST, myurl);
                        JSONObject jsonValue = new JSONObject();
                        jsonValue.put("name", new JSONString("Abc"));
                        builder.setHeader("Content-Type", "application/json");
                        try {
                            Request request = builder.sendRequest(jsonValue.toString(),
                                    new RequestCallback() {
                                        public void onError(Request request,
                                                Throwable exception) {
                                            processResponse("ERROR");
                                        }
                                        public void onResponseReceived(
                                                Request request,
                                                Response response) {
                                            if (200 == response.getStatusCode()) {
                                                processResponse(response
                                                        .getText());
                                            } else {
                                                processResponse("ERROR");
                                            }
                                        }
                                    });
                        } catch (RequestException e) {
                            processResponse("ERROR");
                        }
                    }
                });
public void processResponse(String responseString) {
    Window.alert(responseString);
}
I can see that the post request goes out and the request payload is a json-object. However, when I try to access the data in the php script, I get the error that the index name is undefined.
Here's the PHP:
<?php
echo $_POST["name"];
?>
Is there something wrong with my PHP?
Does anyone have a working example for this?
 
     
    