views:

372

answers:

4

Hello everybody, I'm trying to make comments on my page just like the ones in wordpress. When you press post comments your page updates without reload. How can I do that?

I understand I have to use jquery post, and I've had several attempts but for some reason my web page keeps reloading. I have a form like this :

<form name="postForm" id="postForm" action="addComments.php" method="post">
<textarea name="commentContent"></textarea>
<input type="submit" name="commentButton" id="commentButton">
</form>

I tried $("#commentButton").click(function() do something .. but I still get the page reload. I mean I have the php part ready, working with page reload like an ordinary form just fine, just I'd like to learn and do this without page reload. Any idea how can I make this happen?

A: 

$('#postForm').submit(function() ...

roman
this will still submit the form with loading the page...
Reigel
Now its not working at all
c0mrade
I had error and yes it reloaded the web page
c0mrade
This will not reload the page if you return false - i thought this is common knowlede - my bad
roman
A: 

try using http://www.malsup.com/jquery/form/. It is jQuery plugin to submit form without page load... hope it will help you..

Reigel
Is it compatible with latest jquery? If not it will save me some time :D tnx
c0mrade
it is compatible... I'm always using it... :))
Reigel
Hmm I made progress but for some reason I get errors with firebug jQuery is not defined and $ is not defined, but it works ..
c0mrade
I don't know why you didn't get more vote up this is really gr8
c0mrade
A: 

There is a great tutorial I found while i was searching something similar like adding, deleting comments without page refresh.

http://www.9lessons.info/2009/11/insert-delete-with-jquery-and-ajax.html

roxX
A: 
Tatu Ulmanen