0

我找到了一个 JS-Jquery 文件,几乎可以满足我的需要。如果您单击复选框,它会调用一个 php 函数。现在我想添加另一个复选框来调用另一个 php 函数。

所以我试图复制该功能。并更改值,但这不起作用。

我相信您会在 1-2 秒内看到错误,因此感谢您在JS-Fiddle中的简短查看!

这部分我想复制,也可以在 JS-Fiddle 中查看我的尝试

$('input[name="ive-read-this"]').change(function (evt) {
    alert("markiere als gelesen.");

    // We can retrieve the ID of this post from the <article>'s ID. 
    // This will be required
    // so that we can mark that the user has read this particular post and 
    // we can hide it.
    var sArticleId, iPostId;

    // Get the article ID and split it - the second index is always 
    // the post ID in twentyeleven
    sArticleId = $("article").attr('id');
    iPostId = parseInt(sArticleId.split('-')[1]);

    // Initial the request to mark this this particular post as read
    $.post(ajaxurl, {        
        action:  'mark_as_read',
        post_id: iPostId      
    }
4

1 回答 1

0

我只是忘了添加这个:

add_action('wp_ajax_mark_as_unread',数组(&$this,'mark_as_unread'));

所以解决了!问候

于 2012-11-12T08:34:57.117 回答