I have a form that can be cloned via jquery. I can submit all the inputs if I use:
<form method="POST" action="insert_mydata.php" id="myForm">
But if I try to use:
$(function() {
    $("#myForm").submit(function() {
        $.ajax({
            type: "POST",
            url: "insrt_mydata.php",
            data: $('#myForm').serialize(),
            success: function(data) {
                alert(data);
                alert("Successful");
            }
        });
        return false;
    });
});
Please help me find out what I am missing. Thank you.
The script I am using to clone the form:
$('.add').click(function(e){
    e.preventDefault();
    var lastRepeatingGroup = $('.repeatingSection').last();
    var cloned = lastRepeatingGroup.clone(true);
    cloned.insertAfter(lastRepeatingGroup).find(":text").val("");
    resetAttributeNames(cloned);
});
How does the two method differ from each other as the latter is working (Data are being inserted the way I want it to be), while the jquery method is not. Thank you.
