weixin_33705053 2015-07-24 19:38 采纳率: 0%
浏览 29

Wordpress Ajax响应0

I'm searching for an answer here for hours, and I can't find what's wrong with my code... my wordpress ajax keeps responding "0" no matter what I do... Here's the code:

header.php file:

wp_enqueue_script('js_'.$__page, NEVAL_ASSETS."js/js_course_{$__page}.js", array("jquery"));

js_course_all.js File:

var filter = jQuery("#input_filter").val()+"%";

var data = {
    "action": "course_showall_refresh",
    "data": {
        "sort": _sorting.col,
        "sort_dir": (_sorting.dir) ? 'asc':'desc',
        "filter": filter
    }
};

jQuery.post(ajaxurl, data, function(response){
    alert(response);
});

view .php file:

function refresh(){
    echo 'ajax_response';
    die();
}
add_action("wp_ajax_course_showall_refresh", "refresh");
add_action("wp_ajax_nopriv_course_showall_refresh", "refresh");

The .JS is being correctly imported (the alert goes off with a "0" answer, other functions (UI functions) work correctly.

  • 写回答

2条回答 默认 最新

  • weixin_33720452 2015-07-24 19:43
    关注

    Try doing this. It might solve your problem.

    jQuery.post(ajaxurl, data, function(response){
        alert(response);
    }, 'text');
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?