Thursday, June 11, 2009

.

The stateChanged() and GetXmlHttpObject functions are the same as in the PHP AJAX Suggest chapter.

The getVote() Function

This function executes when "yes" or "no" is selected in the HTML form.

  1. Calls the GetXmlHttpObject() function to create an XMLHTTP object
  2. Defines the URL (filename) to send to the server
  3. Adds a parameter (vote) to the URL with the content of the input field
  4. Adds a random number to prevent the server from using a cached file
  5. Each time the readyState property changes, the stateChanged() function will be executed
  6. Opens the XMLHTTP object with the given url.
  7. Sends an HTTP request to the server

The PHP Page

The server page called by the JavaScript code is a simple PHP file called "poll_vote.php".

No comments:

Post a Comment