Form variable does not refresh with ajax call

Posted by ChrisOPeterson on Stack Overflow See other posts from Stack Overflow or by ChrisOPeterson
Published on 2011-01-15T00:37:09Z Indexed on 2011/01/15 0:53 UTC
Read the original article Hit count: 186

Filed under:
|
|

I'm building a simple email sending form and wanted to make it with ajax. The form submits correctly the first time but if you make any subsequent changes to the text in the form and then submit again then jquery does not pick up on the changes and posts the old data. Whats going on?

<script type="text/javascript">
var $j = jQuery.noConflict();

$j(document).ready(function() {
    var submit_url = "mail_submit.php";
    var send_email = $j("#sendemail");

    send_email.click(function() {
        var form = $j("#post");

        $j.post(submit_url, form.serialize(), function(data) {
            alert(data);
        });

    });
});

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery