O'Reilly logo

jQuery Mobile Cookbook by Chetan K Jain

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Submitting a form using POST

This recipe shows you how to POST and submit a form using Ajax and also how to submit the same forum when not using Ajax. The Blog Comments form used in the previous recipe is used here for submission.

Getting ready

Copy the full code of this recipe from the code/05/submit-form sources folder. This code can be launched using the URL http://localhost:8080/05/submit-form/main.html. To try out this recipe, you will also need to launch the simple nodejs web server that is shipped along with the source code of this book. Launch the server by using the following command:

node jqmserver.js

How to do it...

  1. In main.html, create the Blog Comments form as shown in the following code:
    <form id='commentform' action='/postComment' ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required