B
B
Boris2019-06-16 17:32:42
AJAX
Boris, 2019-06-16 17:32:42

How to pass form data with dynamic id?

There is a dynamically rendered form:
php code:

<button type="button" id="send">Отправить</button>
<form  id="<?php echo $table;?>" style="display:inline-block">
    <input type="text" name="marza" style="width: 30px" value="">
    <input type="hidden" name="table" value="<?php echo $table;?>">
</form>

script:
<script>
$('#send').click(function(){
            $.post(
               'change.php', 
               $(??????).serialize(),
                function(msg) {
                    alert(" отправлено!");
                }
            );
        });
        </script>

What to write in $(??????).serialize() to make it work. I went through a bunch of options, everything does not work!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2019-06-16
@Stalker_RED

$('form').on('submit', function() {
  $(this).serialize()
  // ...
})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question