在wordpress中,ajax加载不起作用

In wordpress ajax load doesn't work

本文关键字:加载 不起作用 ajax wordpress      更新时间:2023-09-26

我已经尝试了以下代码加载word-press register表单时,一个将点击链接寄存器,但它不工作。

<div class="section-register"></div>
<a class="get-register" href="<?php echo wp_registration_url(); ?>">Register</a>
<script>
jQuery(document).ready(function() {
    jQuery('a.get-register').click( function(e) {
        var url = jQuery(this).attr('href');
        jQuery("div#section-register").load(url, "form#registerform");
        e.preventDefault();
    });
});
</script>

请帮。

你的标记是<div class="section-register"></div>

和你通过id选择div将jQuery("div#section-register").load(url, "form#registerform");更改为

jQuery("div.section-register").load(url, "form#registerform");

将标记更改为<div id="section-register"></div>