Monday, October 1, 2012

GWT: Get and Post

Hey I'm trying to send a Get and multiple Posts to a server that then replies accordingly. The server is PHP, and handles the request the following way:

switch($_GET['action'])
{
case 'login':
$response = Account::login($_POST['username'], $_POST['password']);
break;
case 'logout':
$response = Account::logout();
break;
case 'submitChat':
$response = Chat::submitChat($_POST['room'],$_POST['message']);
break;

default:
throw new Exception('bad action');
}

basically the Get chooses what method to pick in the AJAX.php, and the Post delivers the parameters. I'm able to get this to work using HTML forms (coded manually), where clicking submit on the form sends a Get value of "login" and 2 simultaneous Post values of "usernameHere" and "password" which are then handled by AJAX correctly.

How do I do this in GWT programatically? I've found RequestBuilder.sendRequest but this seems to only either send a Get or a Post, not both, and it seems like I cannot send multiple Posts like I want to. Any small example code would be greatly appreciated! Thanks!

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/4qattmswwqUJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment