AJAX评论框与wordpress

时间:2014-06-23 19:00:15

标签: jquery ajax wordpress

我正在尝试使用Ajax在使用wordpress的网站中创建一个评论部分,并尝试将其与jQuery中的php文件链接起来。我已经尝试了所有可能的方法,但它不起作用。请帮忙!我总是得到这个错误:

POST http:// localhost /ajax/comment_insert.php 404(未找到)

我试过添加斜线,删除斜线......一切!仍然没有工作!

$(document).ready(function(){

$('#comment-post-btn').click( function(){

    var _comment = $('#comment-post-text').val();
    var _userId = $('#userId').val();
    var _userName = $('#userName').val();

    if (_comment.length > 0 && _userId != null ) {

        $('#comment-insert-container').css('border', '1px solid #e1e1e1');


        $.post("/ajax/comment_insert.php", {

            task: "comment_insert",
            userId: _userId,
            comment:_comment 

        },

        function( data ){

            console.log("ResponseText: " + data);

        }

    );



        console.log(_comment + "User Name: " + _userName + "User Id:" + _userId );

    } else {

        $('#comment-insert-container').css('border', '1px solid #ff0000');
        console.log("text area emopty");

    }



    //remove text from text area to insert another comment
    $('#comment-post-text').val("");

});

});

PHP代码所有我想要做的是$ _REQUEST这里是php代码:

`

print_r($_REQUEST);

>`

我在wamp服务器上运行它

0 个答案:

没有答案