duandong1869 2018-03-05 05:46
浏览 93

脚本不在jQuery .on事件中处理jQuery load()

I have to make the WordPress post pages to load through AJAX because I think that is a hassle on the user experience and one more things is I don't want to display: https://mydomain/dashboard/page/2 on the URL. Here is the things:

Everything seems to load perfectly through AJAX with the use of this code:

jQuery(document).ready(function($) {
    $("body").on('click', '.job-page a', function(e){
    e.preventDefault();
    var link = $(this).attr('href');
        $('#my-jobs-content').fadeOut(0, function(){
            $("#hb_job_list").load(link + ' #hb_job_list', function() {
                $("#my-jobs-loader").hide();
                $(this).fadeIn(500);
            });
        });
    $("#my-jobs-loader").show();
    });
});

However, there is a button on the page that is loaded that have a script and I'm not able to make it work. I tried to make the .on to .live but it returns 404 ajax error. Any tips?

  • 写回答

1条回答 默认 最新

  • douhu7807 2018-03-05 06:22
    关注

    means the ajax cal working and you get 404 in ajax response status code ?. then probably the link var is not worked properly check the link var points to correct endpoint. since the ajax call getting triggered on click event there's is no issue using 'on' or 'live' both will work.

    评论

报告相同问题?

悬赏问题

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