CSShunt is the most frequent updated css inspiration gallery and logo inspiration gallery.which shows best css websites,logo inspirations,More of that it acts as a portal, so, besides a link to your website we post your description, keywords and title. you can submit your best website (and we encourage that), we verify it and post it in less than 24 hours. csshunt have more different section about some other inspirations as Graphic Design gallery, Designer's Inspiration work with some other cool stuff like freebies ,Web design and development related Articles,Web Design and Web Development Resources.so checkout our updated css inspiration gallery,logo inspiration gallery daily and don't forget to left your suggestions.

Simple AJAX Commenting System

This time, we are making a Simple AJAX Commenting System. It will feature a gravatar integration and demonstrate how to achieve effective communication between jQuery and PHP/MySQL with the help of JSON.

Step 1 – XHTML

First, lets take a look at the markup of the comments. This code is generated by PHP in the Comment class, which we are going to take a look at in a moment.

demo.php

01 <div class="comment">
02 <div class="avatar">
03 <a href="http://tutorialzine.com/">
05 </a>
06 </div>
07
08 <div class="name"><a href="http://tutorialzine.com/">Person's Name</a></div>
09 <div title="Added at 06:40 on 30 Jun 2010" class="date">30 Jun 2010</div>
10 <p>Comment Body</p>
11 </div>

The avatar div contains a hyperlink (if the user entered a valid URL when submitting the comment) and an avatar image, which is fetched from gravatar.com. We will return to this in the PHP step of the tut. Lastly we have the name and time divs, and the comment body.

The other important element in the XHTML part is the comment form. It is sent via POST. All fields except for the URL field are required.

demo.php

01 <div id="addCommentContainer">
02 <p>Add a Comment</p>
03 <form id="addCommentForm" method="post" action="">
04 <div>
05 <label for="name">Your Name</label>
06 <input type="text" name="name" id="name" />
07
08 <label for="email">Your Email</label>
09 <input type="text" name="email" id="email" />
10
11 <label for="url">Website (not required)</label>
12 <input type="text" name="url" id="url" />
13
14 <label for="body">Comment Body</label>
15 <textarea name="body" id="body" cols="20" rows="5"></textarea>
16
17 <input type="submit" id="submit" value="Submit" />
18 </div>
19 </form>
20 </div>

The form is submitted via AJAX. The validation is performed entirely in the backend by submit.php, as you will see in the jQuery step of the tutorial. Every field has a corresponding label element, with an appropriate for attribute.

Download Demo

Related Posts :

Posted on Monday, September 13th, 2010 at 5:07 am | Category: Ajax |

Web Design Blogs
webdesign blog