weixin_33727510 2014-11-28 22:42 采纳率: 0%
浏览 10

一次和两次阿贾克斯

$(function(){

$('a.ajaxLink').click(function(e){
    var l = $(this).attr("href"),
    getdata;
    if(l != null){
    e.preventDefault();
    $.ajax({
       type:'GET',
        url:l + '#book',

        success:function(result){

            getdata = $(result).find('#book');
            //$('#content').html(getdata);
            $('#content').fadeOut(function(){
                $('#book').remove();
                $('#content').append(getdata);
            });

                $('#content').fadeIn(function(){
                pos();
                });
        }
    });
    }
});

});

Hello, I have this code as above :) but there is a problem with the other files Loads multiple addresses with ajaxLink and then ajax does not work. It is something like this: the first click loads the partition with in the background the second click on a loaded by ajax page no longer works.

  • 写回答

2条回答 默认 最新

  • csdnceshi62 2014-11-28 22:46
    关注

    Looks like you replace the whole page or a part which contains your link, so the event bindning will no longer work. To make it work you should use jquery on function.

    $(document).on('click', 'a.ajaxLink', function(e){.... your handler goes here})
    
    评论

报告相同问题?

悬赏问题

  • ¥15 onlyoffice编辑完后立即下载,下载的不是最新编辑的文档
  • ¥15 求caverdock使用教程
  • ¥15 Coze智能助手搭建过程中的问题请教
  • ¥15 12864只亮屏 不显示汉字
  • ¥20 三极管1000倍放大电路
  • ¥15 vscode报错如何解决
  • ¥15 前端vue CryptoJS Aes CBC加密后端java解密
  • ¥15 python随机森林对两个excel表格读取,shap报错
  • ¥15 基于STM32心率血氧监测(OLED显示)相关代码运行成功后烧录成功OLED显示屏不显示的原因是什么
  • ¥100 X轴为分离变量(因子变量),如何控制X轴每个分类变量的长度。