复制Ajax请求函数,调用php函数,noob之类的东西

复制Ajax请求函数,调用php函数,noob之类的东西,php,javascript,jquery,ajax,wordpress,Php,Javascript,Jquery,Ajax,Wordpress,我找到了一个JS Jquery文件,它几乎满足了我的需要。如果单击该复选框,它将调用php函数。现在我想添加另一个复选框,它调用另一个php函数 所以我试着复制这个函数。并更改值,但这不起作用 我相信你会在1-2秒钟内看到错误,因此,感谢您在中的简短介绍 这部分我想复制,也看到我在JS小提琴的尝试 $('input[name="ive-read-this"]').change(function (evt) { alert("markiere als gelesen."); //

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

所以我试着复制这个函数。并更改值,但这不起作用

我相信你会在1-2秒钟内看到错误,因此,感谢您在中的简短介绍

这部分我想复制,也看到我在JS小提琴的尝试

$('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      
    }
$('input[name=“ive read this”]”)。更改(函数(evt){
警惕(“markiere als gelesen”);
//我们可以从的ID检索此帖子的ID。
//这是必需的
//这样我们就可以标记用户已经阅读了这篇文章
//我们可以把它藏起来。
sArticleId变种,Ipstid;
//获取文章ID并将其拆分-第二个索引始终为
//邮政编码是2111
sArticleId=$(“article”).attr('id');
iPostId=parseInt(sArticleId.split('-')[1]);
//初始请求将此特定帖子标记为已读
$.post(ajaxurl,{
行动:'标记为已读',
post_id:iPostId
}

我忘了添加以下内容:

添加操作('wp_ajax_标记为未读',数组(&$this,'mark_为未读')

所以问题解决了!
关于

发布您复制的代码..您在哪里得到错误..而不是正在工作的..::)修复你的小提琴中的语法错误。@bipen不起作用的那一个在JS小提琴中。@Mickylaaad修复了,效果更好,但我在标记为未使用某些调试工具以确定问题的来源时收到了错误消息。例如,你可以使用Chrome的开发工具或Firebug作为前端,使用Xdebug作为后端。