0

I had written an old javascript file which includes some functions and I want to call some of them within JQuery, so how can I get the form object as in this code check_form(frmAddDominate,'<?php echo $_SESSION[sesLang]; ?>') I put the form name "frmAddDominate" because I failed to get its name as variable, anybody have idea?

And here is the complete code:

<script>
    $(document).ready(function() {
        $("#dominateSubmitForm").click(function() {
            if (check_form(frmAddDominate, '<?php echo $_SESSION[sesLang]; ?>')) {
                var form = $(this).closest("form").attr('id');
                var formURL = $('#' + form).attr("action");
                var formData = $('#' + form).serialize();

                $.ajax({
                    type: 'POST',
                    url: formURL,
                    data: formData,
                    success: function(response) {
                        //$('#' + form).find('.form_result').html(response);
                        $("#txtHint").html(response);
                    }
                });
            }
        });
    });
</script>
0

1 Answer 1

5

Use $(this).closest('form')[0] to get the form element

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.