weixin_33671935 2016-01-08 10:37 采纳率: 0%
浏览 44

使用.ajaxQueue问题

It was suggested to me to use ajaxQueue to solve the problems I was having with loading text with ajax in the order I need it to load.

I gave a look at the script, I tried using is, but I can't seem to figure out how it's supposed to work.

How do I transform something that looks like this

    $.ajax({
    url: 'text/example.txt',
    success: function(text){
            document.getElementById("main").innerHTML = document.getElementById("main").innerHTML + text;
    }
});

To use ajaxqueue?

Is there any simple way to do it without rewriting the whole thing?

Please don't flag this as duplicate I read any thread I could find but I have no idea what to do

  • 写回答

1条回答 默认 最新

  • weixin_33676492 2016-01-08 10:52
    关注

    If you are using jQuery then you can merge two html by this way.

    $('#html-1').prepend($('#html-2').html()).prev().remove();
    

    In your case,

    $.ajax({
        url: 'text/example.txt',
        success: function(text){
               $('#main').prepend(text).prev().remove();
        }
    });
    
    评论

报告相同问题?