'Destination DIV' disappearing in simple jQuery AJAX call

前端 未结 5 422
说谎
说谎 2021-01-24 21:35

Edit: Important: It is extremely unlikely that anybody who has come across this will have the exact same problem as me - check my answer below for my very obscu

5条回答
  •  有刺的猬
    2021-01-24 22:19

    Wow! Well that was crazy.

    Turns out the problem is because of this code that I have in an included JS file:

     jQuery.fn._init = jQuery.fn.init
     jQuery.fn.init = function(selector, context) {
         if (typeof selector === 'string') {
             return jQuery.fn._init(selector, context).data('selector', selector);
         }
         return jQuery.fn._init(selector, context);
     };
    

    I am using jQuery 1.2.6.

    The code above came from this post How do I get a jQuery selector's expression as text?. i think the author since rewrote it, but its breaking this for some strange reason.

    The DIV just disappears - but i got thrown because replaceWith() DID work and so did append(). I guess some of the other methods mus internally being tripped up by this but those two werent.

    Thanks for everyones quick suggestions. I'm sure they'll help out others some point.

提交回复
热议问题