Running ajax call on specific form name

This question already has an answer here:

  • How can I select an element by name with jQuery? 15 answers

  • 您可以使用名称选择器$('form[name="myFormName"]') ,如下所示:

    $('form[name="myFormName"]').on('submit', function (e) {
    e.preventDefault();
    
              $.ajax({
                type: 'post',
                url: '<?php echo $config['website']['url']; ?>/assets/hk/ajax/muteorban.php',
                data: $(this).serialize(), ///////// <<<<<<<<<<<<< you can use $(this) here
                success: function (data) {
                  var div = document.getElementById('contentArea_muteorban');
              div.innerHTML = div.innerHTML + data;
                }
              });
    
            });
    
          });
    
    链接地址: http://www.djcxy.com/p/36264.html

    上一篇: 我甚至可以在JavaScript中使用元素的名称?

    下一篇: 在特定的表单名称上运行ajax调用