Connection Manager POST Transaction

To construct a POST transaction using the Connection Manager, you will need to construct a data string as the POST message. The following code example provides a step-by-step approach to creating a simple POST transaction.

Source file and dependencies

Load the YAHOO namespace and connection manager source file:

Assemble the POST message

Construct an example of key-value string of username = anonymous and userid = 0:

The Callback Object

Create a callback object to handle the response and pass an array of values to success and failure as the argument.

Initiate the POST Transaction

Call YAHOO.util.Connect.asyncRequest to send the request to post.php, and the PHP file will return the a readable output of $_POST via print_r(). The handleSuccess callback will print the response object's properties, including the server response data.