Ajax and the POST Method

Passing information to PHP programs using a GET is useful for most situations in which you want to send information to a server-side program and when that information will easily fit in a URL. Sometimes, however, you want to send more information than can easily be put into a URL. For those cases, it's best to use the POST method to send information to a server-side program.

The POST method is usually used in combination with an HTML form, such as the one shown in Figure 16-11.

A typical HTML form

Figure 16-11. A typical HTML form

The code for the standard HTML form shown in Figure 16-11 might look like this:

<form method = "POST" action = "http://www.somesite.com/program_name"> ...

Get The Book of JavaScript, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.