How to do a doOnce function?
<p>How to do a doOnce function?</p>

<p>I have this jQuery script and I want to add a doOnce function to it.
I want to click a tag and submit this function database once, but when I do it update the last updated insert not the current one.</p>

<p>Any help would be great.</p>

<pre><code>$("document").ready(function() {
    $(".edit_happening").click(function() {
        var element = $(this);
        var edit_id = element.attr("id");
        var edit_title = $("#edit_title&lt;?php echo $id; ?&gt;").val();
        var edit_start_time = $("#edit_start_time&lt;?php echo $id; ?&gt;").val();
        var edit_end_time = $("#edit_end_time&lt;?php echo $id; ?&gt;").val();
        var edit_description = $("#edit_description&lt;?php echo $id; ?&gt;").val();
        var edit_location = $("#edit_location&lt;?php echo $id; ?&gt;").val();
        var info = "edit_id=" 
            + edit_id 
            + '&amp;edit_title=' 
            + edit_title
            + '&amp;edit_start_time=' 
            + edit_start_time 
            + '&amp;edit_end_time=' 
            + edit_end_time 
            + '&amp;edit_description=' 
            + edit_description 
            + '&amp;edit_location=' 
            + edit_location;

        if (edit_title == 'Edit Happening') {
            $("#errorMsg_edit&lt;?php echo $id; ?&gt;").fadeIn(200).show();
        }
        else if (edit_description == '') {
            $("#errorMsg_edit&lt;?php echo $id; ?&gt;").fadeOut(200).hide();
            $("#errorMsg2_edit&lt;?php echo $id; ?&gt;").fadeIn(200).show();
        }
        else {
            $.ajax({
                type: "POST",
                url: "/happening_edit.php",
                data: info,
                cache: false,
                success: function(html) {
                    $("#title&lt;?php echo $id; ?&gt;").html(edit_title);
                    $("#happening_edit_info&lt;?php echo $id; ?&gt;").fadeOut(200).hide();
                    $("#happening_info&lt;?php echo $id; ?&gt;").fadeIn(200).show();
                    $("#happening_msg_edit&lt;?php echo $id; ?&gt;").show();
                    setTimeout(function() {
                        $("#happening_msg_edit&lt;?php echo $id; ?&gt;").fadeOut(200).hide();
                    }, 3000);
                }
            });
        }
        return false;
    });
});​
</code></pre>
