When it comes to interacting with web servers, there are a wide range of techniques, each of which is particularly suited for a given application. Two of the most common of these are the GET and POST request methods contained within the web’s HTTP protocol.
While the GET request provides only a URL and the necessary headers to the server, POST requests incorporate a message body that allows for arbitrary data lengths, multiple data types and the specification of these types within the POST header. This is especially useful when an application must send data to a web server, for example, when uploading a file or submitting a form, such as a membership request (“join” form) or blog comment.
While the GET request provides only a URL and the necessary headers to the server, POST requests incorporate a more complex message body.
jQuery coders have an easy option for posting data to a server using HTTP POST via the jQuery.post() command.
In its simplest incarnation, the command syntax for posting a page using jQuery is: $.post(“xbiz.php”); — although this call can be expanded with all sorts of additional information that can be manipulated with callbacks and other techniques. For example, the following will post a web page’s data and then echo it back — a useful method for verifying the submitted data on a web form:
$.post(‘xbiz.php’, function(data) {$(‘.echo’).html(data);});
You can find several more usage examples in the plugin’s online documentation (api.jquery.com/jQuery.post).